Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Labels |
| Date | 2015-08-15 20:20 -0400 |
| Organization | Self |
| Message-ID | <55CFD75B.6020102@verizon.net> (permalink) |
| References | <21f52d2c-4f30-4ae1-9f0a-c1c82527b884@googlegroups.com> <mqnsnd$2c5$1@dont-email.me> <874mk0goix.fsf@bsb.me.uk> <55CFC58E.5090600@verizon.net> <87mvxsf713.fsf@bsb.me.uk> |
On 08/15/2015 07:47 PM, Ben Bacarisse wrote: > James Kuyper <jameskuyper@verizon.net> writes: > >> On 08/15/2015 06:44 PM, Ben Bacarisse wrote: >>> Bartc <bc@freeuk.com> writes: >>> <snip> >>>> Is 'A*B' an expression, or is it declaring a variable B of type >>>> pointer-to-A? >>>> >>>> Is 'F(G)' a function call to G with argument G, or is it declaring a >>>> variable G of type F, or is it the start of function declaration, or >>>> the start of function definition? >>>> >>>> I think you have your work cut out! >>> >>> This makes it sound as if C is particularly hard to parse, but it isn't, >>> provided you know how to handle typedefs. After reading a typedef, the >>> parser must mark the identifiers involved as referring to types. >> >> As earlier messages in this thread have shown, you can't always do that >> immediately after parsing the identifier - the identifier could be a >> statement label, and you have to read the next token after the >> identifier to rule out that possibility. > > I'm taking about what the parse must do once it has parsed a full > typedef declarator. So am I. I'm talking about a use of the typedef, not the declaration of the typedef. After parsing the full typedef declarator, if you find an identifier with the same name at the start of a new line, it could be the first token of a declaration, or the first token of a labeled statement, with a label that happens to be the same as the typedef name. Therefore, you can't mark it as a type until you've read the next token and determined that it's not ':'. > ... I don't see any connection with the original issue > of labels. Until you read the following ':', you can't distinguish a label that has the same name as a typedef from a typedef used as the first token of a declaration. And that's one of the three reasons (the other two are object names and function names) why the ':' must (in some cases) be read before a statement label can be unambiguously identified as such. >> This doesn't strike me as a big >> problem, but David Kleinecke finds it so. > > Yes, any introductory book on parsing will explain how to handle > look-ahead for languages like C. They won't all explain the typedef > issue which is why I tried to explain it.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 09:46 -0700
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-15 14:49 -0400
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 18:48 -0700
Re: Labels Bartc <bc@freeuk.com> - 2015-08-15 18:27 +0100
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-15 23:44 +0100
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-15 19:04 -0400
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-16 00:47 +0100
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-15 20:20 -0400
Re: Labels Bartc <bc@freeuk.com> - 2015-08-16 01:56 +0100
Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-15 19:47 -0700
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-16 11:59 -0400
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-16 22:42 +0100
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-16 20:39 -0400
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-17 03:16 +0100
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 19:01 -0700
Re: Labels Bartc <bc@freeuk.com> - 2015-08-16 01:11 +0100
Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-15 19:13 -0700
Re: Labels Bartc <bc@freeuk.com> - 2015-08-16 10:34 +0100
Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-16 13:58 -0700
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-16 20:42 -0700
Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-16 21:24 -0700
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-17 18:01 -0700
Re: Labels Bartc <bc@freeuk.com> - 2015-08-17 11:04 +0100
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 19:04 -0700
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-16 23:55 +0100
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 19:00 -0700
csiph-web