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


Groups > comp.lang.c > #67548

Re: Labels

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: Labels
Date 2015-08-16 23:55 +0100
Organization A noiseless patient Spider
Message-ID <87zj1qetcq.fsf@bsb.me.uk> (permalink)
References <21f52d2c-4f30-4ae1-9f0a-c1c82527b884@googlegroups.com> <mqnsnd$2c5$1@dont-email.me> <874mk0goix.fsf@bsb.me.uk> <mqokd9$qv5$1@dont-email.me>

Show all headers | View raw


Bartc <bc@freeuk.com> writes:

> On 15/08/2015 23:44, 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,
>
> I was making the point that if the OP thought detecting labels was
> tricky, then other bits of syntax are worse.

OK, I see.  But (as you say later) that's a very low bar -- you might as
well have picked any of a dozen places where the syntax is "as hard to
parse" as labels.

Given your previously expressed antagonism to C's syntax, I thought you
were really saying that C is intrinsically hard to parse, not simply
that there are other constructs that as easy as the one DK was seeing a
problem with.

By the way, I suspect the problem he sees is because of *how* he wants
to parse C, rather than anything specific to the grammar of the
language.  As you say, labels aren't particularly hard, but he may have
set certain constraints on the process that is causing the problem.

<snip>
> But even knowing a starter symbol is a typedef name, then with 'T('
> you might still be a long way from knowing if this is a simple
> variable declaration, or the start of a 1000-line function definition.

Yes.  I think there are some places where you might want to re-factor
the grammar as given in the standard.  Both of your cases start the same
way (as a declarator) and I suspect you have to parse them like that,
only deciding on what to do when you see if you have function body.

I admit I may be over-simplifying it (but then again I may be over
complicating it).  But, in the end, I think the techniques one needs can
be found in standard texts.  In contrast (if memory serves) the authors
of Algol 68 compilers needed to come up with some new tools to get the
job done.

-- 
Ben.

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


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