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


Groups > comp.lang.c > #389541

Re: question about linker

From Ike Naar <ike@sdf.org>
Newsgroups comp.lang.c
Subject Re: question about linker
Date 2024-12-11 08:43 +0000
Organization A noiseless patient Spider
Message-ID <slrnvlik4j.ns4.ike@iceland.freeshell.org> (permalink)
References (23 earlier) <vj1bss$325uo$1@dont-email.me> <vj1h4i$335q1$2@dont-email.me> <vj1mhi$34p7h$1@dont-email.me> <vj1prj$35je4$1@dont-email.me> <vj7dup$he7i$1@dont-email.me>

Show all headers | View raw


On 2024-12-09, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> An unambiguous grammar is something quite essential; how would you
> parse code if it were ambiguous?

Here's an ambiguity in the C grammar:

    <statement>:
        ...
        <selection-statement>
        ...

    <selection-statement>:
        ...
        if ( <expression> ) <statement>
        if ( <expression> ) <statement> else <statement>
        ...

The following selection-statement is grammatically ambiguous:

    if (E1) if (E2) S1 else S2

it has two possible parsings:

    if (E1) <statement> else S2

    where <statement> expands to

        if (E2) S1

or

    if (E1) <statement>

    where <statement> expands to

        if (E2) S1 else S2

The grammatical ambiguity is resolved by an additional rule in the
'Semantics' section for selection-statement:

  3 An else is associated with the lexically nearest preceding if that is
    allowed by the syntax.

gcc -Wall will issue a warning for such an ambiguous statement:

    warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]

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


Thread

Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-07 12:34 +0100
  Re: question about linker Bart <bc@freeuk.com> - 2024-12-07 13:04 +0000
    Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-07 15:36 +0100
      Re: question about linker Bart <bc@freeuk.com> - 2024-12-07 15:33 +0000
        Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-07 13:38 -0800
          Re: question about linker Bart <bc@freeuk.com> - 2024-12-07 22:47 +0000
        Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-09 19:46 +0100
          Re: question about linker bart <bc@freeuk.com> - 2024-12-11 02:21 +0000
            Re: question about linker antispam@fricas.org (Waldek Hebisch) - 2024-12-11 14:39 +0000
              Re: question about linker bart <bc@freeuk.com> - 2024-12-11 15:34 +0000
                Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-11 14:06 -0800
                Re: question about linker bart <bc@freeuk.com> - 2024-12-12 00:02 +0000
                Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-11 16:42 -0800
                Re: question about linker bart <bc@freeuk.com> - 2024-12-12 01:14 +0000
                Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-11 17:27 -0800
                Re: question about linker bart <bc@freeuk.com> - 2024-12-12 11:48 +0000
                Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-12 12:50 -0800
                goto considered helpful (Was: question about linker) Michael S <already5chosen@yahoo.com> - 2024-12-12 14:44 +0200
                Re: goto considered helpful Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-12 13:50 -0800
                Re: goto considered helpful Kaz Kylheku <643-408-1753@kylheku.com> - 2024-12-12 22:33 +0000
                Re: goto considered helpful David Brown <david.brown@hesbynett.no> - 2024-12-13 09:50 +0100
                Re: goto considered helpful bart <bc@freeuk.com> - 2024-12-13 11:12 +0000
                Re: goto considered helpful Michael S <already5chosen@yahoo.com> - 2024-12-13 14:39 +0200
                Re: goto considered helpful David Brown <david.brown@hesbynett.no> - 2024-12-13 14:31 +0100
                Re: goto considered helpful David Brown <david.brown@hesbynett.no> - 2024-12-13 14:19 +0100
                Re: goto considered helpful bart <bc@freeuk.com> - 2024-12-13 14:26 +0000
                Re: goto considered helpful David Brown <david.brown@hesbynett.no> - 2024-12-13 17:52 +0100
                Re: goto considered helpful Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-13 10:11 -0800
                Re: goto considered helpful scott@slp53.sl.home (Scott Lurndal) - 2024-12-13 14:16 +0000
                Re: goto considered helpful Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-13 14:50 +0100
                Re: goto considered helpful (Was: question about linker) Rosario19 <Ros@invalid.invalid> - 2024-12-20 13:52 +0100
                Re: goto considered helpful (Was: question about linker) Michael S <already5chosen@yahoo.com> - 2024-12-20 15:27 +0200
                Re: goto considered helpful (Was: question about linker) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-12-24 09:05 -0800
                Re: goto considered helpful (Was: question about linker) Rosario19 <Ros@invalid.invalid> - 2024-12-26 13:33 +0100
                Re: goto considered helpful (Was: question about linker) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-12-28 09:29 -0800
                Re: question about linker Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-12-12 06:54 -0800
            Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-11 17:24 +0100
              Re: question about linker bart <bc@freeuk.com> - 2024-12-12 12:11 +0000
                Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-12 15:56 +0100
          Re: question about linker Ike Naar <ike@sdf.org> - 2024-12-11 08:43 +0000
            Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-11 16:28 +0100
              Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-11 17:46 +0100
                Re: question about linker antispam@fricas.org (Waldek Hebisch) - 2024-12-12 02:31 +0000
            Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-11 17:30 +0100
              Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-11 17:47 +0100
                Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-11 17:51 +0100
                Re: question about linker bart <bc@freeuk.com> - 2024-12-11 17:20 +0000
                Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-11 21:46 +0100
                Re: question about linker bart <bc@freeuk.com> - 2024-12-11 21:19 +0000
                Re: question about linker Michael S <already5chosen@yahoo.com> - 2024-12-12 00:03 +0200
                Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-12 11:08 +0100
                Re: question about linker Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-12-23 16:02 -0800
                Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-12 05:50 +0100
                Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-11 21:35 -0800
                Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-12 12:38 +0100
                Re: question about linker James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-12-18 16:04 -0500
                Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-19 01:35 +0100
                Re: question about linker James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-12-19 06:39 -0500
                Re: question about linker antispam@fricas.org (Waldek Hebisch) - 2024-12-19 14:58 +0000
                Re: question about linker bart <bc@freeuk.com> - 2024-12-12 12:29 +0000
                Re: question about linker Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-12-12 07:01 -0800
                Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-11 21:36 +0100
          Re: question about linker antispam@fricas.org (Waldek Hebisch) - 2024-12-11 13:59 +0000
    Re: question about linker Bart <bc@freeuk.com> - 2024-12-07 14:57 +0000
      Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-07 16:19 +0100
        Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-07 16:28 +0100
      Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-07 13:44 -0800
        Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-07 13:58 -0800
          Re: question about linker scott@slp53.sl.home (Scott Lurndal) - 2024-12-07 22:15 +0000
    Re: question about linker antispam@fricas.org (Waldek Hebisch) - 2024-12-11 22:51 +0000
      Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-11 15:12 -0800
      Re: question about linker bart <bc@freeuk.com> - 2024-12-12 00:52 +0000

csiph-web