comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Interesting article on ARG work
Date: Mon, 9 Apr 2018 19:12:54 +0300
Date: 2018-04-09T19:12:54+03:00	[thread overview]
Message-ID: <fj1ho6Fbv06U1@mid.individual.net> (raw)
In-Reply-To: <1a390e22-f49f-4028-8e58-ca4d0f51e4b6@googlegroups.com>

On 18-04-08 22:48 , Dan'l Miller wrote:
> On Sunday, April 8, 2018 at 2:46:15 AM UTC-5, Dmitry A. Kazakov wrote:
>>     if Foo then
>> @     Bar;
>> @  end if;
>> @  if Boo then
>>        Baz;
>>     end if;
>>
>> would not be legal either.
>
> Where ␠ is the ASCII/ISO646 space character (presented as
> a graphical character for visualization herein),
>
>     if Foo then
> ␠     Bar;
> ␠  end if;
> ␠  if Boo then
>        Baz;
>     end if;
>
> and
>
>     if Foo then
> --     Bar;
> --  end if;
> --  if Boo then
>        Baz;
>     end if;
>
> both are legal Ada statements, spurious and non sequitur
> evocations of the ARM notwithstanding.

I'm sure that Dmitry understands fully how the "@" mechanism currently 
works in Janus/Ada: as a lexical marker that either makes the line 
visible to the parser and compiler, or makes it into a comment line that 
is essentially invisible (white space) to the parser and compiler.

As Randy showed, it is then easy to make editing mistakes that make one 
of the two resulting source-code forms grammatically incorrect.

I think Dmitry is suggesting that to avoid such problems, the inclusion 
or exclusion of code parts should not be done on the lexical level, line 
by line, but should be better integrated into the grammatical structure 
so that the included or excluded pieces of code would be whole 
grammatical structures, with grammatically defined boundaries.

> In general, Dmitry, you seem to not understand that a generalized
> left-right (GLR) parser would parse both sides of the @ concurrently.
> Your entire premise is that it is impossible to parse both presence
> and absence of @ at the same time.  In GLR, you are incorrect.

I don't think that GLR parsing solves this problem. Firstly, I assume 
that you are thinking of non-deterministic grammar rules in which  "@ 
<construct>" could be parsed either into "<construct>", understanding 
the "@" option as "enabled", or into whitespace, understanding the "@" 
option as "disabled". Well and good, but the GLR parser would apply this 
nondeterministic choice separately at each occurrence of a "@", so there 
would be an exponentially large set of alternative parse attempts.

For example, the text

     if Foo then
        Bar;
@   else
@      Baz;
     end if;

would be parsed in four ways, according to the four combinations of 
choices (enabled/disabled) for the two @ signs:

First way (disabled - disabled):

    if Foo then
       Bar;
    end if;

Second way (enabled - disabled):

    if Foo then
       Bar;
    else
    end if;

Third way (disabled - enabled):

    if Foo then
       Bar;
       Baz;
    end if;

Fourth way (enabled - enabled):

    if Foo then
       Bar;
    else
       Baz;
    end if;

Only the first and fourth ways correspond to how "@" works in Janus/Ada. 
The second way is even syntactically illegal, but an error message from 
a GLR parser would be quite confusing to a Janus/Ada user.

For GLR to work for this problem, you would have to extend it with some 
kind of "uniform choice" rule, by which all non-determinism depending on 
the use of "@" should follow a single, global, non-deterministic choice.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


  parent reply	other threads:[~2018-04-09 16:12 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-02  3:32 Interesting article on ARG work Randy Brukardt
2018-04-02 14:49 ` Dan'l Miller
2018-04-03 16:34   ` Bojan Bozovic
2018-04-03 22:33     ` Randy Brukardt
2018-04-04  2:12       ` Bojan Bozovic
2018-04-04 15:05       ` Dan'l Miller
2018-04-04 15:30         ` gerdien.de.kruyf
2018-04-04 16:09           ` Dan'l Miller
2018-04-04 22:30         ` Randy Brukardt
2018-04-04 22:43           ` Paul Rubin
2018-04-05  0:44             ` Mehdi Saada
2018-04-05 21:23               ` Randy Brukardt
2018-04-05  2:05           ` Bojan Bozovic
2018-04-05 22:12             ` Randy Brukardt
2018-04-06 13:35               ` Bojan Bozovic
2018-04-07  2:01                 ` Randy Brukardt
2018-04-05  7:21           ` Dmitry A. Kazakov
2018-04-05 22:18             ` Randy Brukardt
2018-04-06  7:30               ` Dmitry A. Kazakov
2018-04-07  2:25                 ` Randy Brukardt
2018-04-07 10:11                   ` Dmitry A. Kazakov
2018-04-07 15:27                     ` Dan'l Miller
2018-04-07 15:59                       ` Dmitry A. Kazakov
2018-04-08  0:14                         ` Dan'l Miller
2018-04-08  7:46                           ` Dmitry A. Kazakov
2018-04-08 19:48                             ` Dan'l Miller
2018-04-08 20:09                               ` Dmitry A. Kazakov
2018-04-09  3:50                                 ` Dan'l Miller
2018-04-09  6:40                                   ` Jan de Kruyf
2018-04-09  7:43                                   ` Dmitry A. Kazakov
2018-04-09 13:40                                     ` Dan'l Miller
2018-04-09 14:13                                       ` Dmitry A. Kazakov
2018-04-09 14:36                                         ` Dan'l Miller
2018-04-09 14:44                                           ` Dmitry A. Kazakov
2018-04-09 15:03                                             ` Dan'l Miller
2018-04-09 16:12                               ` Niklas Holsti [this message]
2018-04-09 16:30                                 ` Dmitry A. Kazakov
2018-04-09 16:45                                   ` Niklas Holsti
2018-04-09 17:33                                     ` Dan'l Miller
2018-04-09 19:47                                     ` Dmitry A. Kazakov
2018-04-09 20:24                                   ` Randy Brukardt
2018-04-10  8:17                                     ` Dmitry A. Kazakov
2018-04-09 18:08                                 ` Dan'l Miller
2018-04-09 21:17                                   ` Niklas Holsti
2018-04-09 22:09                                     ` Dan'l Miller
2018-04-10 19:23                                       ` Niklas Holsti
2018-04-10 19:46                                         ` Dan'l Miller
2018-04-15  7:50                                           ` Niklas Holsti
2018-04-15 13:31                                             ` Dan'l Miller
2018-04-15 18:37                                               ` Niklas Holsti
2018-04-09 20:14                       ` Randy Brukardt
2018-04-06 23:49               ` Dan'l Miller
2018-04-12 10:21                 ` Marius Amado-Alves
2018-04-15 13:07                   ` Ada conditional compilation and program variants Niklas Holsti
2018-05-07  8:41                     ` Jacob Sparre Andersen
2018-04-06 13:35 ` Interesting article on ARG work Marius Amado-Alves
2018-04-07  2:15   ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox