Re: Whaddaya think?

Liste des GroupesRevenir à cl c  
Sujet : Re: Whaddaya think?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.c
Date : 19. Jun 2024, 03:58:57
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240618181840.18@kylheku.com>
References : 1 2 3 4 5 6 7 8 9
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-06-19, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
Kaz Kylheku <643-408-1753@kylheku.com> writes:
>
Speaking of while, the do/while construct does not require parentheses
in order to disambiguate anything, since it has a mandatory semicolon.
Yet, it still has them.
>
It has them to allow an extension for a "loop-and-a-half" control
structure:
>
    do statement while ( expression ) statement
>
and so for example
>
    do  c = getchar();  while(  c != EOF  )  n++;
>
to count characters on standard input.
>
Oh?  Do you have any evidence that that was the intent? [...]
>
I think you're reading something into my remark that it
didn't say.
>
Or at least that you didn't mean.

FWIW, it would seem that the phrase pattern:

    do statement while expression ;

may be compatible with the proposed extension in a way
manageable via LALR(1) parsing.

I don't see difficulties in recursive descent, either.

The near minimal Yacc grammar pasted below produces no conflicts,
and is only slightly contorted. We treat the ')' token as the
lowest prededence operator, and ';' as highest, which eliminates
conflicts in way that we want.

I can explain why; another way is to remove the %nonassoc declarations,
use "yacc -v", and study the confict details y.output file.

It's not clear whether the grammar can be nicely factored into the form
used in the standard, which makes no use of precedence or associativity.
(But would that be a requirement for leaving room for an extension.)

%{

%}

%nonassoc ')'
%token DO WHILE NUM
%left '+'
%nonassoc ';'

%%

while_statement : DO statement WHILE expr ';'
                | DO statement WHILE '(' expr ')' statement

statement : ';'
          | expr ';'
          | '{' expr '}'
          | '{' '}'
          ;

expr : '(' expr ')'
     | expr '+' expr
     | '+' expr
     | NUM
     ;

%%

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
15 Jun 24 * Whaddaya think?96DFS
15 Jun 24 +- Re: Whaddaya think?1Malcolm McLean
16 Jun 24 +* Re: Whaddaya think?5Ben Bacarisse
16 Jun 24 i+* Re: Whaddaya think?2bart
16 Jun 24 ii`- Re: Whaddaya think?1Ben Bacarisse
16 Jun 24 i`* Re: Whaddaya think?2DFS
17 Jun 24 i `- Re: Whaddaya think?1Ben Bacarisse
16 Jun 24 +* Re: Whaddaya think?23Keith Thompson
16 Jun 24 i`* Re: Whaddaya think?22DFS
16 Jun 24 i +- Re: Whaddaya think?1Keith Thompson
17 Jun 24 i +* Re: Whaddaya think?19James Kuyper
17 Jun 24 i i+- Re: Whaddaya think?1Tim Rentsch
17 Jun 24 i i+* Re: Whaddaya think?13Kaz Kylheku
17 Jun 24 i ii+- Re: Whaddaya think?1Chris M. Thomasson
17 Jun 24 i ii+* Re: Whaddaya think?6DFS
17 Jun 24 i iii`* Re: Whaddaya think?5Richard Harnden
17 Jun 24 i iii +- Re: Whaddaya think?1David Brown
23 Jun 24 i iii `* Re: Whaddaya think?3Kaz Kylheku
23 Jun 24 i iii  +- Re: Whaddaya think?1Keith Thompson
23 Jun 24 i iii  `- Re: Whaddaya think?1Phil Carmody
18 Jun 24 i ii`* Re: Whaddaya think?5Tim Rentsch
18 Jun 24 i ii `* Re: Whaddaya think?4Keith Thompson
19 Jun 24 i ii  `* Re: Whaddaya think?3Tim Rentsch
19 Jun 24 i ii   `* Re: Whaddaya think?2Keith Thompson
19 Jun 24 i ii    `- Re: Whaddaya think?1Kaz Kylheku
17 Jun 24 i i`* Re: Whaddaya think?4DFS
17 Jun 24 i i `* Re: Whaddaya think?3Ben Bacarisse
18 Jun 24 i i  `* Re: Whaddaya think?2Janis Papanagnou
18 Jun 24 i i   `- Re: Whaddaya think?1Keith Thompson
17 Jun 24 i `- Re: Whaddaya think?1James Kuyper
16 Jun 24 +* Re: Whaddaya think?60Michael S
16 Jun 24 i+* Re: Whaddaya think?58Lawrence D'Oliveiro
16 Jun 24 ii`* Re: Whaddaya think?57Janis Papanagnou
16 Jun 24 ii +* Re: Whaddaya think?8Keith Thompson
16 Jun 24 ii i+- Re: Whaddaya think?1Lawrence D'Oliveiro
16 Jun 24 ii i`* Re: Whaddaya think?6Janis Papanagnou
16 Jun 24 ii i `* Re: Whaddaya think?5DFS
16 Jun 24 ii i  `* Re: Whaddaya think?4David Brown
16 Jun 24 ii i   +* Re: Whaddaya think?2bart
17 Jun 24 ii i   i`- Re: Whaddaya think?1David Brown
17 Jun 24 ii i   `- Re: Whaddaya think?1DFS
16 Jun 24 ii +* Re: Whaddaya think?45Janis Papanagnou
16 Jun 24 ii i`* Re: Whaddaya think?44Keith Thompson
16 Jun 24 ii i `* Re: Whaddaya think?43Janis Papanagnou
16 Jun 24 ii i  +* Re: Whaddaya think?20Keith Thompson
16 Jun 24 ii i  i`* Re: Whaddaya think?19Janis Papanagnou
16 Jun 24 ii i  i +* Re: Whaddaya think?2Malcolm McLean
16 Jun 24 ii i  i i`- Re: Whaddaya think?1Janis Papanagnou
16 Jun 24 ii i  i `* Re: Whaddaya think?16Keith Thompson
17 Jun 24 ii i  i  `* Re: Whaddaya think?15Janis Papanagnou
17 Jun 24 ii i  i   +* Re: Whaddaya think?12Keith Thompson
17 Jun 24 ii i  i   i`* Re: Whaddaya think?11Janis Papanagnou
17 Jun 24 ii i  i   i +* Re: Whaddaya think?5James Kuyper
18 Jun 24 ii i  i   i i+- Re: Whaddaya think?1Keith Thompson
18 Jun 24 ii i  i   i i`* Re: Whaddaya think?3Janis Papanagnou
18 Jun 24 ii i  i   i i +- Re: Whaddaya think?1James Kuyper
18 Jun 24 ii i  i   i i `- Re: Whaddaya think?1Keith Thompson
18 Jun 24 ii i  i   i `* Re: Whaddaya think?5Keith Thompson
18 Jun 24 ii i  i   i  +- Re: Whaddaya think?1Janis Papanagnou
19 Jun 24 ii i  i   i  `* Re: Whaddaya think?3Keith Thompson
19 Jun 24 ii i  i   i   `* Re: Whaddaya think?2David Brown
19 Jun 24 ii i  i   i    `- Re: Whaddaya think?1Keith Thompson
17 Jun 24 ii i  i   `* Re: Whaddaya think?2James Kuyper
17 Jun 24 ii i  i    `- Re: Whaddaya think?1Janis Papanagnou
16 Jun 24 ii i  +* Re: Whaddaya think?7Michael S
16 Jun 24 ii i  i`* Re: Whaddaya think?6Janis Papanagnou
16 Jun 24 ii i  i `* Re: Whaddaya think?5Michael S
16 Jun 24 ii i  i  `* Re: Whaddaya think?4Janis Papanagnou
16 Jun 24 ii i  i   `* Re: Whaddaya think?3Michael S
16 Jun 24 ii i  i    `* Re: Whaddaya think?2Janis Papanagnou
16 Jun 24 ii i  i     `- Re: Whaddaya think?1Michael S
17 Jun 24 ii i  `* Re: Whaddaya think?15Keith Thompson
17 Jun 24 ii i   +* Re: Whaddaya think?11Tim Rentsch
17 Jun 24 ii i   i+* Re: Whaddaya think?8Janis Papanagnou
17 Jun 24 ii i   ii+* Re: Whaddaya think?6DFS
17 Jun 24 ii i   iii+* Re: Whaddaya think?2Chris M. Thomasson
18 Jun 24 ii i   iiii`- Re: Whaddaya think?1Keith Thompson
18 Jun 24 ii i   iii+* Re: Whaddaya think?2Keith Thompson
18 Jun 24 ii i   iiii`- Re: Whaddaya think?1David Brown
18 Jun 24 ii i   iii`- Re: Whaddaya think?1Janis Papanagnou
18 Jun 24 ii i   ii`- Re: Whaddaya think?1Tim Rentsch
17 Jun 24 ii i   i`* Re: Whaddaya think?2James Kuyper
19 Jun 24 ii i   i `- Re: Whaddaya think?1Tim Rentsch
17 Jun 24 ii i   `* Re: Whaddaya think?3Janis Papanagnou
17 Jun 24 ii i    `* Re: Whaddaya think?2Keith Thompson
17 Jun 24 ii i     `- Re: Whaddaya think?1Janis Papanagnou
16 Jun 24 ii +- Re: Whaddaya think?1Malcolm McLean
16 Jun 24 ii `* Re: Whaddaya think?2Michael S
16 Jun 24 ii  `- Re: Whaddaya think?1Janis Papanagnou
16 Jun 24 i`- Re: Whaddaya think?1DFS
16 Jun 24 `* Re: Whaddaya think?6Lew Pitcher
16 Jun 24  +- Re: Whaddaya think?1Malcolm McLean
18 Jun 24  +- Re: Whaddaya think?1Lawrence D'Oliveiro
25 Jun 24  `* Re: Whaddaya think?3Lew Pitcher
25 Jun 24   `* Re: Whaddaya think?2DFS
25 Jun 24    `- Re: Whaddaya think?1Lew Pitcher

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal