[C++ PATCH] Make parser revert digraph "<:"

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Jan 26 15:57:00 GMT 2004


"Giovanni Bajo" <giovannibajo@libero.it> writes:

| Gabriel Dos Reis wrote:
| 
| >> That being said, for the problem at hand it might be an overkill and
| >> the scheme has also to be tested when there are other syntax errors
| >> further in the program.
| >
| > For the problem at hand, we know what the value of the token is.  It
| > is the value of the token '['.  The issue is to determine whether it
| > was spelt '[' or '<:' for diagnostic purpose only.  So, it is not a
| > case where we really have a tentative parsing.
| 
| No, it's not only a diagnostic issue. If you check my patch, I emit a
| diagnostic only to be fully ISO compliant. If you comment the errors out, my
| code makes the parser accept "A<::B>" without whitespaces and go on with the
| compilation correctly. I use tentative parsing to achieve this.

You misunderstood what I was saying.  Maybe with symbols, I'll have
more chance.

    vector<::foo> x;
    vector[:foo> y;

!   /* If we find the sequence `[:' after a template-name, it's probably
!      a digraph-typo for `< ::'. Substitute the tokens and check if we can
!      parse correctly the argument list.  */

-- Gaby



More information about the Gcc-patches mailing list