comp.lang.ada
 help / color / mirror / Atom feed
From: maa@liacc.up.pt (Mário Amado Alves)
Subject: Re: parse word from a string
Date: 15 Nov 2002 03:12:08 -0800
Date: 2002-11-15T11:12:08+00:00	[thread overview]
Message-ID: <4a4de33a.0211150312.4180a570@posting.google.com> (raw)
In-Reply-To: u3cq4yroo.fsf@wanadoo.fr

"If you are using GNAT be sure to look at GNAT.AWK. (Pascal)"

"Uhg, no! Look at GNAT.Spitbol ;-)" (MAA)
 
"I disagree :) GNAT.AWK handles files directly. In GNAT.Spitbol you
still have to open and read each lines. And since the problem at hand
seems to justslice a string with a set of separators, GNAT.AWK seems
just fine ;)" (Pascal)

Actually the original problem is "read words from a file", and for
that a simple character automaton in 'pure' Ada suffices, e.g.

  C : Character
  Word : Unbounded_String;
begin
  loop
    Get_Immediate (C);
    if Is_Graphic (C) and C /= ' ' then
      Append (Word, C);
    else
      Process (Word);
      Word := Null_Unbounded_String;
    end if;
  end loop;
exception
  when End_Error =>
    if Word /= Null_Unbounded_String then Process (Word); end if;

I was just advocating Spitbol over AWK in the case of general pattern
matching. You seem to agree that Spitbol might be better for complex
problems. And Spitbol is also good enough for simple problems. Ergo,
Spitbol is better ;-)

More seriously, it is better strictly in a Reduced Technology Mix
framework.

Again, for the simple problem at hand, I follow Robert Dewar's famous
adage: "don't use pattern matching".

Cheers,
--MAA



      reply	other threads:[~2002-11-15 11:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-12 19:25 parse word from a string Sarah Thomas
2002-11-12 21:36 ` Michal Nowak
2002-11-13  9:46 ` Pascal Obry
2002-11-13 17:23   ` Mário Amado Alves
2002-11-14 17:41     ` Pascal Obry
2002-11-15 11:12       ` Mário Amado Alves [this message]
replies disabled

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