Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #148129

Re: How to parse attributes?

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: How to parse attributes?
Date 2019-11-23 00:08 +0000
Organization A noiseless patient Spider
Message-ID <87o8x35u9y.fsf@bsb.me.uk> (permalink)
References (3 earlier) <87blt47is6.fsf@bsb.me.uk> <lnwobsy12n.fsf@kst-u.example.com> <qr87c4$tah$1@dont-email.me> <87tv6v6by3.fsf@bsb.me.uk> <lnftifyc74.fsf@kst-u.example.com>

Show all headers | View raw


Keith Thompson <kst-u@mib.org> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>> David Brown <david.brown@hesbynett.no> writes:
>>> On 22/11/2019 05:41, Keith Thompson wrote:
>> <cut>
>>>> There is precedent in C++ for dealing with nested <> template
>>>> delimiters, but that was needed because >> is already a token.  Any
>>>> problems with [[ and ]] didn't require such a solution.
>>>
>>> For a long time (until C++11), you needed to use "> >" to close the
>>> nested template.  In C++11, ">>" was allowed for closing the nested
>>> templates.  That meant that any C++ compiler supporting C++11 had to
>>> find a solution to this problem, which may have meant changing their
>>> parser or tokeniser significantly.  C++ front ends do not use lex/yacc
>>> parsers any more - this is an example of why they don't.
>>>
>>> So when attributes were included in C++, the reason there was no
>>> problems in using "]]" to end them despite "]]" being interpreted as "]
>>> ]" in other situations, is that C++ compilers already had the facilities
>>> in place to deal with that.
>>
>> Oh!  Are [[ and/or ]] single tokens in C++'s attributes?  If so, what a
>> shame there is now another difference with C.  If not, I don't see the
>> connection with >> since neither [[ nor ]] are single tokens. There is,
>> in C, no need for any special mechanism at all.
>
> No, the C++ attribute syntax for an attribute-specifier is:
>
>     attribute-specifier:
>         [ [ attribute-using-prefix opt attribute-list ] ]
>         alignment-specifier
>
> C++ has a special case for treating >> as two > tokens in the context of
> templates, so that you can write
>     std::vector<std::vector<int>>
> rather than
>     std::vector<std::vector<int> >
> (which was necessary in older versions of C++, before C++11 I think).
>
> C and C++ attribute syntaxes appear to be reasonably consistent.

Yes, my question was somewhat rhetorical.  I thought it vanishing
unlikely that C and C++ diverged on this issue.  Hence my being puzzled
by DB's suggestion that ]] would not be a problem (in C++) because of
"the facilities in place" to deal with >>.

> You suggested that treating [[ as a single token would make
> parsing attributes easier,

I did not intend to.  I wanted to say that it would simplify using a
tool like lex (so that any special lexical considerations inside
attributes could be self-contained) but I think the remark came out as
too general.

<cut>
-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to parse attributes? Philipp Klaus Krause <pkk@spth.de> - 2019-11-20 09:41 +0100
  Re: How to parse attributes? David Brown <david.brown@hesbynett.no> - 2019-11-20 10:05 +0100
    Re: How to parse attributes? Philipp Klaus Krause <pkk@spth.de> - 2019-11-20 11:05 +0100
      Re: How to parse attributes? David Brown <david.brown@hesbynett.no> - 2019-11-20 12:35 +0100
  Re: How to parse attributes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-20 11:06 +0000
  Re: How to parse attributes? Öö Tiib <ootiib@hot.ee> - 2019-11-20 23:16 -0800
    Re: How to parse attributes? Philipp Klaus Krause <pkk@spth.de> - 2019-11-21 10:39 +0100
      Re: How to parse attributes? Öö Tiib <ootiib@hot.ee> - 2019-11-21 02:51 -0800
        Re: How to parse attributes? James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-11-21 05:00 -0800
      Re: How to parse attributes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-22 02:21 +0000
        Re: How to parse attributes? Keith Thompson <kst-u@mib.org> - 2019-11-21 20:41 -0800
          Re: How to parse attributes? Philipp Klaus Krause <pkk@spth.de> - 2019-11-22 09:15 +0100
          Re: How to parse attributes? David Brown <david.brown@hesbynett.no> - 2019-11-22 09:48 +0100
            Re: How to parse attributes? "A. K." <minforth@arcor.de> - 2019-11-22 02:00 -0800
              Re: How to parse attributes? David Brown <david.brown@hesbynett.no> - 2019-11-22 11:41 +0100
              Re: How to parse attributes? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-11-24 14:02 +0000
                Re: How to parse attributes? raltbos@xs4all.nl (Richard Bos) - 2019-11-25 16:21 +0000
            Re: How to parse attributes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-22 17:46 +0000
              Re: How to parse attributes? Keith Thompson <kst-u@mib.org> - 2019-11-22 10:53 -0800
                Re: How to parse attributes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-23 00:08 +0000
    Re: How to parse attributes? scott@slp53.sl.home (Scott Lurndal) - 2019-11-21 15:57 +0000
    Re: How to parse attributes? Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-22 08:21 +0100
    Re: How to parse attributes? Bart <bc@freeuk.com> - 2019-11-22 12:11 +0000

csiph-web