Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #148072
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: How to parse attributes? |
| Date | 2019-11-20 11:06 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <871ru2958j.fsf@bsb.me.uk> (permalink) |
| References | <qr2u7d$lo5$1@solani.org> |
Philipp Klaus Krause <pkk@spth.de> writes:
> C2X has attributes.
> Implementation in the front-end seems straigtforward, except for one
> bit: Keywords are treated as normal identifiers in attributes.
>
> E.g. the following
>
> int i;
>
> void f(void)
> {
> [[const::int]] i++;
> }
>
> is valid C.
>
> So far, a plain lex / yacc parser, would recognize keywords as tokens in
> the lexer, where we don't know if we're in an attribute-specifier.
> That makes it hard to allow keywords in attributes. Of course one could
> create lots of rules for yacc for all the individual keywords, but that
> doesn't look like a clean solution to me.
>
> Is there an easy solution that I overlooked?
My first thought is that it should be simple. Can you not have the grammar
rules for attributes use an "attribute_id" rule that includes keywords?
Maybe that this what you are trying to avoid... If so I'd try to handle
this with lex start conditions. It should be relatively simple to treat
symbols inside [[ ... ]] differently at the lexical level, but I've not
checked the C specification.
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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