From: Grzegorz J. <ja...@ac...> - 2004-07-18 10:01:19
|
Stefan Seefeld wrote: > Grzegorz Jakacki wrote: > >> It is worse. 'f<1>(0)' will always parse as a template, even if 'f' is >> an int variable. :-( >> >>> Could I simply add ';' >>> and ',' to the list of symbols potentially following the template args ? >> >> >> >> AFAICS it will not break things further. >> >>> May be I should have a look into the new C++ parser used in gcc 3.4... >> >> >> >> Honest parsing of templates requires parser to be able to tell if an >> identifier is a template in current scope and this is how gcc does it >> (gcc/gcc/cp/parser.c, see cp_parser_lookup_name()). > > > Ah, now I understand again ! So, the solution is to add a type dictionary > ('Environment' ?) to the Parser and then let the 'isTypeSpecifier' use that > instead of just detecting built-in types. Right ? For many cases this should work. However in general it will not. The top-level environment is maintained by ClassWalker. Driver in the main loop runs Parser::rProgram() and feeds the obtained AST into ClassWalker. Parser::rProgram() returns AST representing one top-level construct (definition or declaration), so one iteration analyzes one top-level construct. Only when ClassWalker traverses the AST, the information about types defined in it are stuffed into Environment. This is fair enough when there is no namespaces or nested templates. However, if top-level construct is a namespace, then Environment does not have a clue about anything defined in it until it is fully parsed. I don't think there is an easy and complete solution. I have one solution in mind, but it is neither cheap, nor easy. BR Grzegorz > > Stefan > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click > _______________________________________________ > Opencxx-users mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/opencxx-users |