comp.lang.ada
 help / color / mirror / Atom feed
* Pattern matching
@ 1997-10-07  0:00 Neil Goodgame
  1997-10-08  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 5+ messages in thread
From: Neil Goodgame @ 1997-10-07  0:00 UTC (permalink / raw)



Any Ada packages available to do grep/perl style pattern matching using
regular expression.

NG
-- 
======================================================
Neil Goodgame			Smithkline Beacham
Neil_Goodgame-1@sbphrd.com	
======================================================




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

* Re: Pattern matching
  1997-10-07  0:00 Pattern matching Neil Goodgame
@ 1997-10-08  0:00 ` Matthew Heaney
  1997-10-09  0:00   ` Robert Dewar
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Heaney @ 1997-10-08  0:00 UTC (permalink / raw)



In article <343A068A.41C6@sbphrd.com>, Neil Goodgame
<Neil_Goodgame-1@sbphrd.com> wrote:

>Any Ada packages available to do grep/perl style pattern matching using
>regular expression.

The latest version of GNAT, 3.10p, includes a package to do SNOBOL style
pattern matching.  If you're not using GNAT, you could always download the
source and use just that package with your compiler (I think).

You might want to check the PAL too.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




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

* Re: Pattern matching
  1997-10-08  0:00 ` Matthew Heaney
@ 1997-10-09  0:00   ` Robert Dewar
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1997-10-09  0:00 UTC (permalink / raw)



<<The latest version of GNAT, 3.10p, includes a package to do SNOBOL style
pattern matching.  If you're not using GNAT, you could always download the
source and use just that package with your compiler (I think).>>

Provided that the compiler you use implements Unrestricted_Access in a manner
identical to the implementation in GNAT, that may be true, although a fair
amount of hacking would be required even then (and I suspect that in fact
only GNAT can compile this package). These packages were written with no
attempt to be cross-platform portable, and they rely on the use of
UnrestrictedAccess in a fundfamental manner at the interface.

So for practical purposes, I suspect that these packages are in practice
GNAT specific. 

Robert Dewar
Ada Core Technologies.

P.S. the language is SNOBOL 4, not plain SNOBOL, and indeed it is probably
better to refer to this as SPITBOL style pattern matching anyway. As usual,
the documentation is found in the relevant g-*.ads files. Note that in
addition to full pattern matching capabilities, these packages also
provide associative array capabilities (like Table in SPITBOL).





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

* Pattern Matching
@ 2003-04-20 12:15 bmsv
  2003-04-24 18:22 ` Georg Bauhaus
  0 siblings, 1 reply; 5+ messages in thread
From: bmsv @ 2003-04-20 12:15 UTC (permalink / raw)


Hi.
I have tried to use the Regpat package in order to find occurrences in
a text string. In the packge I read I could get undefined number of
occurrences, but when trying to use it, I says that the variable where
the occurrences will be stored(the Match_array variable) needs
initialization. So is it possible to get an undefined number of
occurrences?
This an example string I have:
city[hotel1,hotel2,hotel3]{restaurant1, restaurant2}
the line could also look like this:
city{restaurant1, restaurant2}[hotel1,hotel2,hotel3]

And I would like to get in one array(or another data type) all the
restaurants, in another one all the hotels and in on single string the
city name.

Any idea how to get this?
thx in advance.



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

* Re: Pattern Matching
  2003-04-20 12:15 Pattern Matching bmsv
@ 2003-04-24 18:22 ` Georg Bauhaus
  0 siblings, 0 replies; 5+ messages in thread
From: Georg Bauhaus @ 2003-04-24 18:22 UTC (permalink / raw)


bmsv <temp2@dagi3d.net> wrote:
: This an example string I have:
: city[hotel1,hotel2,hotel3]{restaurant1, restaurant2}
: the line could also look like this:
: city{restaurant1, restaurant2}[hotel1,hotel2,hotel3]

What I would do is:
Use Regpat to extract the groups, that is,
city                    	match(1).first .. match(1).last
restaurant1, restaurant2	match(2).first .. match(2).last
hotel1,hotel2,hotel3       	etc.

For this, a Match_Array object of Parent_Count length will
suffice. (You can use three groups in an alternative
reflecting the order of {} and [], or a pattern involving
[{[]([^]}]*)[]}], if input is wellformed, or similar.)

Then, split the groups into data structures of your choice,
eg sets.

Using Find_Token and related subprograms from Ada.Strings.Fixed
might be an alternative.

just my 2c
-- Georg



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

end of thread, other threads:[~2003-04-24 18:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-20 12:15 Pattern Matching bmsv
2003-04-24 18:22 ` Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
1997-10-07  0:00 Pattern matching Neil Goodgame
1997-10-08  0:00 ` Matthew Heaney
1997-10-09  0:00   ` Robert Dewar

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