comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: OpenToken: Parsing Ada (subset)?
Date: Tue, 16 Jun 2015 15:24:14 +0200
Date: 2015-06-16T15:24:14+02:00	[thread overview]
Message-ID: <1a08qrccls0bi$.16y7q3hosklae.dlg@40tude.net> (raw)
In-Reply-To: 85pp4vakmy.fsf@stephe-leake.org

On Tue, 16 Jun 2015 07:43:49 -0500, Stephen Leake wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> Yes, it is writing regular expression vs. writing Ada program. I prefer Ada
>> program.
> 
> I'm confused; you start by agreeing with my statement, but then say
> something else.
> 
> I said "implement a general regular expression engine", meaning the Ada
> code that interprets regular expressions at run time. I hope you agree
> that writing that is harder than writing an Ada scanner.
> 
> To address your point; let's compare writing a regular expression with
> writing Ada code to do the same thing.
> 
> Here's the regular expression I use for Ada numeric literals:
> 
> "\([0-9]+#\)?[-+0-9a-fA-F.]+\(#\)?"
> 
> Given that you are at least a little familiar with regular expressions,
> there's nothing hard about that.

It is hard.

> It does not enforce all the lexical rules for numbers; it allows
> repeated, leading, and trailing underscores; it doesn't enforce pairs of
> '#'.

That is exactly the point. It does not parse literal right and you have to
reparse the matched chunk of text once again. What was the gain? Why
wouldn't do it right in single step?

> It took a few minutes to write the regular expression, and I reused the
> tests; no bugs found yet.

> Obviously, if you are not familiar with regular expressions, they will
> be harder to write. But a software engineer should be willing to learn
> the appropriate language for the job at hand.

That is not the point. I am familiar with C, but I am avoiding writing
anything in C. Regular expressions is a far worse language than C and,
additionally, incapable to parse Ada literals. Why bother with that mess?
 
> I would guess that the average good programmer, starting with no
> knowledge of either, can learn enough about regular expressions to write
> the above faster than they can learn enough about writing scanners in
> Ada to do that job well.

The problem is that writing a correct pattern for anything more complex
than trivial is hard even for people doing this on daily basis. For an
average programmer it is patently impossible.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2015-06-16 13:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 13:08 OpenToken: Parsing Ada (subset)? Jacob Sparre Andersen
2015-06-02 22:12 ` Stephen Leake
2015-06-03  1:43   ` Shark8
2015-06-03  7:36     ` Dmitry A. Kazakov
2015-06-05  9:03       ` Stephen Leake
2015-06-05  9:23         ` Georg Bauhaus
2015-06-05 20:49           ` Shark8
2015-06-05 23:52             ` Dennis Lee Bieber
2015-06-05 12:20         ` Dmitry A. Kazakov
2015-06-16 12:43           ` Stephen Leake
2015-06-16 13:24             ` Dmitry A. Kazakov [this message]
2015-06-16 14:13               ` G.B.
2015-06-17 17:38                 ` Stephen Leake
2015-06-17 17:29               ` Stephen Leake
2015-06-17 17:42                 ` Shark8
2015-06-17 19:03                 ` Dmitry A. Kazakov
2015-06-05 20:53         ` Shark8
2015-06-16 14:46           ` Stephen Leake
2015-06-16 15:31             ` G.B.
2015-06-17 17:44               ` Stephen Leake
2015-06-16 21:34             ` Randy Brukardt
2015-06-17 17:58               ` Stephen Leake
2015-06-17 20:44                 ` Randy Brukardt
2015-06-18  7:51                 ` AdaMagica
2015-06-18  9:12                 ` Georg Bauhaus
2015-06-17 17:50 ` AdaMagica
replies disabled

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