From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada grammar rules for names too permissive?
Date: Tue, 1 Jan 2019 09:44:14 +0100
Date: 2019-01-01T09:44:14+01:00 [thread overview]
Message-ID: <q0f98v$1hf2$1@gioia.aioe.org> (raw)
In-Reply-To: q0e2m8$t6b$1@franka.jacob-sparre.dk
On 2018-12-31 22:45, Randy Brukardt wrote:
> Ada semantic rules use the syntax rules and vice versa. In this case, one
> does not want to repeat the various rules for interpreting an expanded name
> (which are part of selected_component).
>
> In this particular case, the resolution rule for subtype_mark eliminates any
> nonsense cases.
>
> There's also two practical considerations: one is that with typical grammar
> generators, you usually have to allow more syntax than you want, as
> differentiating between options requires essentially unlimited lookahead.
> (Most grammar generators use a single token lookahead.) In this case, you
> would have a lot of trouble telling between a type conversion and an indexed
> component, if the prefix syntax was different for each.
>
> Secondly, error detection for generated grammars tends to be less
> understandable than hand written error handling. (My understanding is that
> this is a major reason why GNAT uses a hand-written parser.) So allowing too
> much syntactically allows providing better error messages.
>
> For instance, one could easily require "others" to stand alone with your
> grammar. However, if you do that, the error message ends up being something
> like "unexpected |", which is not very helpful.
This discussion repeats each year! (:-()
Maybe it is worth to write somewhere in c.l.a: attention! Ada needs no
grammar generators! Never push semantic rules into syntax.
The grammar as written is never the one actually used for whatever
purpose other than explanation or, maybe, validation. An extreme case
illustrating why, is source code coloring, but applies to compilers just
same.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2019-01-01 8:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-29 18:20 Ada grammar rules for names too permissive? olivermkellogg
2018-12-31 21:45 ` Randy Brukardt
2019-01-01 8:44 ` Dmitry A. Kazakov [this message]
2019-01-01 19:49 ` Stephen Leake
2019-01-01 20:42 ` Dmitry A. Kazakov
2019-01-02 19:21 ` Stephen Leake
2019-01-02 20:47 ` Dmitry A. Kazakov
2019-01-03 21:45 ` Stephen Leake
2019-01-03 22:34 ` Jere
2019-01-05 18:46 ` Stephen Leake
2019-01-07 11:11 ` J-P. Rosen
2019-01-08 18:58 ` Stephen Leake
2019-01-04 8:53 ` Dmitry A. Kazakov
2019-01-03 22:39 ` olivermkellogg
2019-01-04 8:58 ` Dmitry A. Kazakov
2019-01-05 8:45 ` Randy Brukardt
2019-01-05 18:50 ` Stephen Leake
2019-01-01 19:46 ` olivermkellogg
2019-01-03 22:36 ` Randy Brukardt
2019-01-01 19:46 ` Stephen Leake
2019-01-01 21:03 ` olivermkellogg
2019-01-02 19:42 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox