Trying to find a link for information about parsing template parameters and the >> problem

Alec Teal a.teal@warwick.ac.uk
Mon Apr 1 19:43:00 GMT 2013


On 01/04/13 17:41, Ian Lance Taylor wrote:
> On Mon, Apr 1, 2013 at 8:55 AM, Alec Teal <a.teal@warwick.ac.uk> wrote:
>> I'm still planning to rewrite the c++ parser in GCC, right now I am still researching, I remember a page that talked about the problems of parsing > in nested templates, and I cannot find the link!
>>
>> Searching for it has yielded people asking questions about errors where >> occurs.
>>
>> Please provide me with the link.
> I'm not sure this kind of message really belongs on the
> gcc@gcc.gnu.org mailing list, which is for issues related to the
> development of GCC.  I understand that you are looking at rewriting
> the C++ parser (why?) but this is just a basic C++ question, not a GCC
> issue.
An exercise mainly, the goal would be to better facilitate error report 
generation,  by creating (perhaps with a flag) some sort of AST that may 
be dumped or exported. Exporting headers in this form (and importing 
later) done with a flag of course. Bringing the parser and symbol table 
closer together.
Some things can just be better parsed going from right to left, ; end a 
statement and { } form lovely blocks, reading from right to left 
shouldn't be too bad at all, nor would perhaps threading complication 
(this is just a thought, I know compiling is a task that lends itself to 
being done in parallel rather nicely), with this format too you could 
perhaps (again with flags) store 'notes' about a function with the hash 
of the tokens that make it up, save recompiling an entire file. This 
data wouldn't go inside the object file, and these are just some thoughts.
Having such a note file could be useful if any compiler instance can 
write to it (if the thing it is notes of is being used) to build a 
program-wide callgraph while compiling, I suspect LTO does this already 
within the object file though.
If IDEs could make use of this file it'd be even better. I understand 
I've gotten quite far from "why the parser" now.
> I don't have a link, but it seems to me that the issue is obvious.
> The C++ lexer recognizes >> as a single token.  So when you write
>      std::vector<std::vector<int>>
> the final >> is parsed as a single token, rather than the two separate
> tokens that the parser expects.
Yes that is (was) the problem, I remember reading a document online, I 
cannot recall where that looked at three ways of solving it and 
evaluated them, I know of the problem but I want that guy's evaluation! 
the article spoke about GCC, I'm sure it was under the gnu domain.... 
gah! I wish I could recall!
>
> Note that this issue is fixed in C++11.
>
> Ian
>
Alec



More information about the Gcc mailing list