comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GNAT.Regpat problem.
Date: Fri, 25 Mar 2011 10:02:14 +0100
Date: 2011-03-25T10:02:14+01:00	[thread overview]
Message-ID: <1nldz3m96wp6o.1gxjoy2zlrwon.dlg@40tude.net> (raw)
In-Reply-To: alpine.WNT.2.00.1103241708520.7004@WHIRLWIND

On Thu, 24 Mar 2011 17:12:04 -0400, Peter C. Chapin wrote:

> On Thu, 24 Mar 2011, Dmitry A. Kazakov wrote:
> 
>> So, yes, it is difficult to find a case where RE could find place. And in 
>> general, any patterns are unusable for syntax analyzers for many reasons, 
>> I don't want to go into. A manually written scanner is simpler and safer.
> 
> I did notice that it was harder, I thought, to get high quality error 
> reporting when using packaged REs. I also had a case that used a hand 
> written finite state machine.

I prefer to split it into smaller elements (e.g. "comment," "literal") for
a recursive descent parser and then code them without FSM. I hate FSMs. I
have to use FSM when dealing with layered protocols, which makes me hating
it more and more.

> The code was longer but the error reporting 
> was very specific. I'm not saying it would be impossible to get the same 
> error reporting using REs but it seemed unnatural. Right now my code using 
> REs just reports "Unrecognized input" (or something to that effect) and 
> doesn't bother trying to figure out what's unrecognized and why. It was no 
> big deal to get the hand written FSM to do that, however.

That reminds me one case for patterns I forgot. When you get something
incomprehensible you might wish to jump forward to a place where parser
could recover. E.g. to the end of a comment, to the n-th closing bracket
etc (standard REs cannot count brackets). For this kind of superficial +
error tolerant analysis patterns indeed might be usable. A similar case
would be syntax coloring.

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



  reply	other threads:[~2011-03-25  9:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-22 18:35 GNAT.Regpat problem Peter C. Chapin
2011-03-22 19:01 ` Georg Bauhaus
2011-03-22 19:17 ` Florian Weimer
2011-03-22 19:21 ` Adam Beneschan
2011-03-22 20:31   ` Simon Wright
2011-03-24 10:23     ` Peter C. Chapin
2011-03-24 10:43       ` Dmitry A. Kazakov
2011-03-24 14:04         ` Peter C. Chapin
2011-03-24 14:34           ` Dmitry A. Kazakov
2011-03-24 16:20             ` Georg Bauhaus
2011-03-24 17:37               ` Dmitry A. Kazakov
2011-03-24 21:12             ` Peter C. Chapin
2011-03-25  9:02               ` Dmitry A. Kazakov [this message]
2011-03-24 16:41           ` Georg Bauhaus
replies disabled

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