comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Interesting article on ARG work
Date: Tue, 10 Apr 2018 22:23:21 +0300
Date: 2018-04-10T22:23:21+03:00	[thread overview]
Message-ID: <fj4h99F24e6U1@mid.individual.net> (raw)
In-Reply-To: <195739aa-2f32-4cba-80ac-e60591e94712@googlegroups.com>

On 18-04-10 01:09 , Dan'l Miller wrote:
> On Monday, April 9, 2018 at 4:17:42 PM UTC-5, Niklas Holsti wrote:
>> If there are 2 alternative AST subtrees at each choice point, the
>> total number of possible complete ASTs (which is what the later
>> stages of an ordinary compiler would have to process) is
>> exponential in the number of choice points (that is, "@"
>> instances)
>
> Trivially exponential:  at most 2¹ = 2 alternative AST subtrees as
> some points, because there is only one choice point:  an
> @-code-is-present on the compiler's command-line versus an
> @-code-is-elided on the compiler's command line.

I call a "choice point" a point in the input sentence where the parser 
has to fork into alternatives. For a GLR parser, this means every 
_occurrence_ of an "@" in the input sentence.

You are ignoring my explicitly stated assumption (which follows if one 
is using _just_ a GLR parser) that the choices of alternative at the 
various choice points are uncorrelated. This makes the number of 
combinations of choices, which is the number of alternative _entire_ 
ASTs (in the commonly accepted meaning of AST as _one_ parse of the 
input sentence) exponential in the number of choice points.

The paper to which you referred avoids that problem by associating 
choice points with conditions depending on preprocessor variables, which 
is a natural thing to do, but which also means passing beyond the 
abilities of _just_ GLR parsing.

> Each @-prefixed line is not isomorphic to yet another
> differently-named macro in the C preprocessor (or M4, p4, etc
> preprocessors).

In plain GLR parsing it is isomorphic, because a GLR parser does not 
create any correlations between the non-deterministic choices at 
different points in the sentence. That would be a context-dependent grammar.

> For p choicepoints on
> the compiler command-line, yes you are trivially correct:
> “exponential” 2ᵖ but where p is not only constant, but merely p=1,
> hence GLR's O(pn) asymptotic rate of growth is O(1n) = O(n) and
> likewise for the at-most twice-as-big AST.

That is true for the "Fork-Merge LR" (FMLR) parsing in the paper you 
referenced, but that is not GLR.

> Not @ instances (as counted by lines of code) but @ degrees of
> freedom on the compiler command-line.  You are not counting the
> correct things.

We are certainly counting different things.

You said that GLR parsing could be used to parse both "@ enabled" and "@ 
disabled" sentences at the same time. I maintain that _just_ a GLR 
parser is not suitable, because the uncorrelated choice of alternative 
parses at each choice point (each "@") does not match the meaning of the 
"@" symbol (enabled everywhere, or disabled everywhere).

The FMLR method, with alternatives correlated by logical conditions, 
works, at least if one fully believes the claims in the paper to which 
you referred (I am perhaps not quite convinced that the paper's 
"ifdef-hoisting" will work and remain relatively local in all cases).

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

  reply	other threads:[~2018-04-10 19:23 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
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 [this message]
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