comp.lang.ada
 help / color / mirror / Atom feed
* Re: regular expressions
       [not found] ` <3h1h74$hnh@Starbase.NeoSoft.COM>
@ 1995-02-06  2:39   ` Michael Feldman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Feldman @ 1995-02-06  2:39 UTC (permalink / raw)


In article <3h1h74$hnh@Starbase.NeoSoft.COM>,
David Weller <dweller@Starbase.NeoSoft.COM> wrote:
>In article <3gucrg$2dn@kaiwan009.kaiwan.com>,
>David D. Shochat <dshochat@kaiwan009.kaiwan.com> wrote:
>>Does anyone know of any regular expression pattern matching 
>>tools in Ada? I looked throush the WC CDROM but didn't see
>>anything.

Try AFLEX, an Ada version of Flex (Lex), which I think is on the CD.
It may be a little heavyweight - it is really a lexical scanner builder,
but after all, regular expressions are the language of lexical scanners.

Mike Feldman
------------------------------------------------------------------------
Michael B. Feldman -  chair, SIGAda Education Working Group
Professor, Dept. of Electrical Engineering and Computer Science
The George Washington University -  Washington, DC 20052 USA
202-994-5919 (voice) - 202-994-0227 (fax) - mfeldman@seas.gwu.edu (Internet)
------------------------------------------------------------------------
One, two, three ways an underdog: Ada fan, Mac fan, Old Liberal Democrat
------------------------------------------------------------------------
         Ada on the World-Wide Web: http://lglwww.epfl.ch/Ada/
------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: regular expressions
       [not found] <3gucrg$2dn@kaiwan009.kaiwan.com>
       [not found] ` <3h1h74$hnh@Starbase.NeoSoft.COM>
@ 1995-02-06 23:20 ` John Woodruff
  1 sibling, 0 replies; 5+ messages in thread
From: John Woodruff @ 1995-02-06 23:20 UTC (permalink / raw)


David Shochat  dshochat@logicon.com asks
any regular expression pattern matching tools in Ada?

Booch's book Software Components w Ada, Benjamin Cummings 1987, 
ISBN 0-8053-0610-2 devotes a chapter to pattern matching, including
Knuth-Morris-Pratt and Boyer-Moore implementations. 

The software itself is copyright so you'll need to find a license,
however the text presents (almost?) all of the code in Ada.
-- 
John Woodruff
Lawrence Livermore National Lab
510 422 4661
--
John Woodruff
Lawrence Livermore National Lab
510 422 4661



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: regular expressions
@ 1995-02-08 13:50 Stefan Knappe
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Knappe @ 1995-02-08 13:50 UTC (permalink / raw)



I try to do a pattern matching by using aflex and ayacc. 
if you want these programs i have only the source (6 MBytes). (the binaries are installed
already on the computers before i use this).

Good Bye

Stefan Knappe
mkn@cnve.rz.uni-jena.de



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Regular Expressions
@ 2000-01-16  0:00 Kerry W. Lothrop
  2000-01-17  0:00 ` David C. Hoos, Sr.
  0 siblings, 1 reply; 5+ messages in thread
From: Kerry W. Lothrop @ 2000-01-16  0:00 UTC (permalink / raw)


Hello,

I've just started learning Ada and am having problems extracting
information from a text file (in this case it is a flight logger file).
I'm used to doing these things in Perl, so I've gotten used to regular
expressions, which seem to be available through the package GNAT.Regpat.

My first step is to identify the line I'm searching for. It starts with
an "H", maybe followed by a space, followed by a letter, maybe followed
by a space, followed by "PLT", maybe followed by a space, followed by
"PILOT:". I thought this pattern should be "^H ?. ?PLT ?PILOT:". The
relevant lines in my program are:

   while (not End_Of_File(File => File_Name)) loop
      Get_Line(File => File_Name, Item => Line, Last => Linlen);
      if Match(Expression => "^H ?. ?PLT ?PILOT:", Data => Line(1 ..
Linlen), Size => 10000) then
         Put_Line(Item => Line(1 .. Linlen));
      end if;
   end loop;

The pattern seems to match every line, because the program outputs all
the lines in the data file. If I just write the pattern "PILOT" it picks
out the right line. If I write the pattern "^H" it outputs all lines.

What is it I'm doing wrong? Has anyone worked with GNAT.Regpat?

One more thing: Once I have the line, how do I pick out the data after
the colon?


Thanks,

Kerry





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Regular Expressions
  2000-01-16  0:00 Regular Expressions Kerry W. Lothrop
@ 2000-01-17  0:00 ` David C. Hoos, Sr.
  0 siblings, 0 replies; 5+ messages in thread
From: David C. Hoos, Sr. @ 2000-01-17  0:00 UTC (permalink / raw)



Kerry W. Lothrop <kerry@lothrop.de> wrote in message
news:38824937.78FFA393@lothrop.de...
> Hello,
>
> I've just started learning Ada and am having problems extracting
> information from a text file (in this case it is a flight logger file).
> I'm used to doing these things in Perl, so I've gotten used to regular
> expressions, which seem to be available through the package GNAT.Regpat.
>
> My first step is to identify the line I'm searching for. It starts with
> an "H", maybe followed by a space, followed by a letter, maybe followed
> by a space, followed by "PLT", maybe followed by a space, followed by
> "PILOT:". I thought this pattern should be "^H ?. ?PLT ?PILOT:". The
> relevant lines in my program are:
>
My recollection of the correct RE for what you've described is
"^H ?[a-zA-Z] ?PLT ?PILOT:"
The "." in you expression says "match _any_ character."
I have not used GNAT.Regpat, so I am at a loss as to why every line should
match.
>    while (not End_Of_File(File => File_Name)) loop
>       Get_Line(File => File_Name, Item => Line, Last => Linlen);
>       if Match(Expression => "^H ?. ?PLT ?PILOT:", Data => Line(1 ..
> Linlen), Size => 10000) then
>          Put_Line(Item => Line(1 .. Linlen));
>       end if;
>    end loop;
>
> The pattern seems to match every line, because the program outputs all
> the lines in the data file. If I just write the pattern "PILOT" it picks
> out the right line. If I write the pattern "^H" it outputs all lines.
>
> What is it I'm doing wrong? Has anyone worked with GNAT.Regpat?
>
> One more thing: Once I have the line, how do I pick out the data after
> the colon?
I would use
Line (Ada.Strings.Fixed.Index (Source => Line, Pattern => ":") .. Linlen);







^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-01-17  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-02-08 13:50 regular expressions Stefan Knappe
  -- strict thread matches above, loose matches on Subject: below --
2000-01-16  0:00 Regular Expressions Kerry W. Lothrop
2000-01-17  0:00 ` David C. Hoos, Sr.
     [not found] <3gucrg$2dn@kaiwan009.kaiwan.com>
     [not found] ` <3h1h74$hnh@Starbase.NeoSoft.COM>
1995-02-06  2:39   ` regular expressions Michael Feldman
1995-02-06 23:20 ` John Woodruff

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