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


Groups > comp.lang.c > #120482

Re: Lexical Elements

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Lexical Elements
Date 2017-09-28 12:37 -0700
Organization None to speak of
Message-ID <lnk20iwr59.fsf@kst-u.example.com> (permalink)
References (1 earlier) <m2o9pv33am.fsf@despina.home> <oqht8d$ke3$1@dont-email.me> <e1753783-684f-45a1-8600-e0230fa9ba81@googlegroups.com> <lnmv5eyh4k.fsf@kst-u.example.com> <d7b80520-7c0a-461f-99db-1b58dac1ee15@googlegroups.com>

Show all headers | View raw


David Kleinecke <dkleinecke@gmail.com> writes:
> On Thursday, September 28, 2017 at 8:31:32 AM UTC-7, Keith Thompson wrote:
>> David Kleinecke <dkleinecke@gmail.com> writes:
>> [...]
>> > I think C89 has no concept of "constraint violation" or 
>> > even of "violation". I can be faulted for using C89 of
>> > course but the C89 section 3 does not make any
>> > distinction between kinds of "shall". This seems to
>> > be nit-picking to me.
>> 
>> C89 certainly does have the concept of "constraint violation".
>> See for example C89 2.1.1.3 Diagnostics (5.1.1.3 in C90):
>> 
>>     A conforming implementation shall produce at least one diagnostic
>>     message (identified in an implementation-defined manner) for
>>     every translation unit that contains a violation of any syntax
>>     rule or constraint.  Diagnostic messages need not be produced
>>     in other circumstances.
>  
> This is a nit almost too small to pick. It's 5.1.1.3 in C90. I
> suspect you were looking at the pre-boilerplate version (when the
> first three sections were added.) If so I indeed made an error.
> I should have said C90 not C89.

I wouldn't say it's *almost* too small to pick.  I already quoted the
section numbers for both C89 and C90.

> Note that it does not differentiate between which kind of violation
> occurred. I read "violation" here as the ordinary English word (it
> is not in the index) and not a C technical term.

Correct.  The syntax used by a compiler's parser needn't be 100%
consistent with the language grammar defined by the standard, as long as
correct code is parsed and analyzed correctly and required diagnostics
are issued.

> I think that this and other passages strongly suggest that I should
> consider syntax and constraints together as an integrated system if
> I want to get into the spirit of C. There is no a priori reason for
> doing so and my old compiler integrated the constraints with code
> generation rather than syntax. I am trying to move the constraints
> over to the same processing as the syntax and that's where I 
> stumbled over the concept of "lexical form.

I don't know how you'd treat them as an "integrated system", though I
suppose it depends on just what you mean by that.

A compiler typically treats syntax and semantics separately.  Syntactic
analysis, or parsing, is often semi-automated, with the parser generated
programatically from a forma grammar -- or it might be written manually.
If parsing fails, that's a syntax error.  Other errors, like trying to
apply a shift operator to a pointer value, have to be detected during
semantic analysis.  As far as typical compiler internals are concerned,
they're fundamentally different kinds of errors.  Tweaking the grammar
to treat some syntax errors as semantic errors can enable better
diagnostics in some csaes.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


Thread

Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-27 19:03 -0700
  Re: Lexical Elements "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-09-28 05:33 +0200
    Re: Lexical Elements James Kuyper <jameskuyper@verizon.net> - 2017-09-28 00:19 -0400
      Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-27 22:09 -0700
        Re: Lexical Elements Keith Thompson <kst-u@mib.org> - 2017-09-28 08:31 -0700
          Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 11:53 -0700
            Re: Lexical Elements jameskuyper@verizon.net - 2017-09-28 12:16 -0700
              Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 15:51 -0700
                Re: Lexical Elements jameskuyper@verizon.net - 2017-09-28 16:42 -0700
            Re: Lexical Elements Keith Thompson <kst-u@mib.org> - 2017-09-28 12:37 -0700
              Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 16:16 -0700
                Re: Lexical Elements Keith Thompson <kst-u@mib.org> - 2017-09-28 18:39 -0700
                Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 19:47 -0700
                Re: Lexical Elements jameskuyper@verizon.net - 2017-09-28 20:29 -0700
                Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 22:36 -0700
                Re: Lexical Elements Keith Thompson <kst-u@mib.org> - 2017-09-29 08:47 -0700
                Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-29 11:23 -0700
                Re: Lexical Elements Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-29 18:27 +0100
        Re: Lexical Elements jameskuyper@verizon.net - 2017-09-28 09:13 -0700
    Re: Lexical Elements Richard Damon <Richard@Damon-Family.org> - 2017-09-28 08:15 -0400
  Re: Lexical Elements jameskuyper@verizon.net - 2017-09-27 21:03 -0700
    Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-27 22:16 -0700
      Re: Lexical Elements jameskuyper@verizon.net - 2017-09-28 09:45 -0700
        Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 11:58 -0700
          Re: Lexical Elements jameskuyper@verizon.net - 2017-09-28 12:29 -0700
            Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 15:52 -0700
              Re: Lexical Elements Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-09-28 17:40 -0600
              Re: Lexical Elements jameskuyper@verizon.net - 2017-09-28 16:54 -0700
          Re: Lexical Elements Keith Thompson <kst-u@mib.org> - 2017-09-28 12:40 -0700
            Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 16:12 -0700
          Re: Lexical Elements bartc <bc@freeuk.com> - 2017-09-28 21:04 +0100
            Re: Lexical Elements bartc <bc@freeuk.com> - 2017-09-28 22:12 +0100
            Re: Lexical Elements David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 16:15 -0700
              Re: Lexical Elements bartc <bc@freeuk.com> - 2017-09-29 01:19 +0100

csiph-web