* gnat.spitbol.patterns.match(...) @ 2000-10-05 0:00 bumwad 2000-10-06 0:42 ` gnat.spitbol.patterns.match(...) dale 0 siblings, 1 reply; 9+ messages in thread From: bumwad @ 2000-10-05 0:00 UTC (permalink / raw) I am trying to use gnat's Spitbol/pattern packages to create a string by removing a regexp from one and replacing it with another. for example I have a string "c:\a\b\c\d\foo" and path "c:\a\b\" and another path "c:\x\y\". I want to create "c:\x\y\c\d\foo". I am writing a unifying directory trees utility. env = Nt 4.0, gnat 3.13p here is code .... Base_Dir_from_Pattern : constant Gnat.Spitbol.Patterns.Pattern := Gnat.Spitbol.Patterns.Span("c:\testChamber\t99\"); ... Ada.TExt_Io.Put_Line("Subject = " & Ada.Strings.Unbounded.To_String (Curr_Dir_To_Name_Vstring)); Ada.TExt_Io.Put_Line("Pat = " & Gnat.Spitbol.Patterns.Image (Base_Dir_From_Pattern)); Ada.TExt_Io.Put_Line("Replace = " & Base_Dir_To); Replacement_Successful := Gnat.Spitbol.Patterns.Match (Subject => Curr_Dir_To_Name_Vstring, -- Gnat.Spitbol.Patterns.VString_Var Pat => Base_Dir_From_Pattern, -- pattern Replace => Base_Dir_To -- string ); ADA.Text_IO.NEW_LINE(2); Ada.TExt_Io.Put_Line("Subject = " & Ada.Strings.Unbounded.To_String (Curr_Dir_To_Name_Vstring)); Ada.TExt_Io.Put_Line("Pat = " & Gnat.Spitbol.Patterns.Image (Base_Dir_From_Pattern)); Ada.TExt_Io.Put_Line("Replace = " & Base_Dir_To); ADA.Text_IO.NEW_LINE(5); and output ( go through a loop with a recursive call and dir tree only 2 deep). See that the directory a_dir is missing the initial 'a' after the call on match() but not on a_dir_in_a_dir (!?) .... C:\testChamber>synchem3 Subject = c:\testChamber\t99\a_dir Pat = Span ("9:C\abcehmrst") Replace = c:\testChamber\t100\ Subject = c:\testChamber\t100\_dir Pat = Span ("9:C\abcehmrst") Replace = c:\testChamber\t100\ Subject = c:\testChamber\t99 \a_dir\a_dir_in_a_dir Pat = Span ("9:C\abcehmrst") Replace = c:\testChamber\t100\ Subject = c:\testChamber\t100 \_dir\a_dir_in_a_dir Pat = Span ("9:C\abcehmrst") Replace = c:\testChamber\t100\ Thanks, Keith Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gnat.spitbol.patterns.match(...) 2000-10-05 0:00 gnat.spitbol.patterns.match(...) bumwad @ 2000-10-06 0:42 ` dale 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Robert Dewar 2000-10-06 3:14 ` gnat.spitbol.patterns.match(...) Ted Dennison 0 siblings, 2 replies; 9+ messages in thread From: dale @ 2000-10-06 0:42 UTC (permalink / raw) Mr bumwadwrote: [a whole lot of stuff] ...and i thought Ada was supposed to be readable!!! Dale ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gnat.spitbol.patterns.match(...) 2000-10-06 0:42 ` gnat.spitbol.patterns.match(...) dale @ 2000-10-06 0:00 ` Robert Dewar 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Dale Stanbrough 2000-10-06 3:14 ` gnat.spitbol.patterns.match(...) Ted Dennison 1 sibling, 1 reply; 9+ messages in thread From: Robert Dewar @ 2000-10-06 0:00 UTC (permalink / raw) In article <dale-2D7177.11420406102000@news.rmit.edu.au>, dale <dale@cs.rmit.edu.au> wrote: > Mr bumwadwrote: > > [a whole lot of stuff] > > ...and i thought Ada was supposed to be readable!!! The point to realize here is that this feature in GNAT duplicates the full semantics and also somewhat the syntax of another complex language (SNOBOL-4). You cannot expect to begin to understand code using this feature without putting in the effort to learn this language (which is not trivial). The 20 page tutorial in g-spipat.ads is a bare introduction to the language, but is only that. To fully use this feature, if you are not familiar with SNOBOL-4, you probably need to read some other SNOBOL-4 materials :-) Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gnat.spitbol.patterns.match(...) 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Robert Dewar @ 2000-10-06 0:00 ` Dale Stanbrough 2000-10-07 0:25 ` gnat.spitbol.patterns.match(...) Ted Dennison 0 siblings, 1 reply; 9+ messages in thread From: Dale Stanbrough @ 2000-10-06 0:00 UTC (permalink / raw) Robert Dewar wrote: > The point to realize here is that this feature in GNAT > duplicates the full semantics and also somewhat the syntax > of another complex language (SNOBOL-4). You cannot expect > to begin to understand code using this feature without putting > in the effort to learn this language (which is not trivial). > The 20 page tutorial in g-spipat.ads is a bare introduction > to the language, but is only that. To fully use this feature, > if you are not familiar with SNOBOL-4, you probably need to > read some other SNOBOL-4 materials :-) I didn't have a problem with the Snobol part, (although i find the use of 'Unrestricted_Access can make spitbol code a bit ugly); it was the full package name syntax, and the strange formatting that i found hard to cope with. Dale ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gnat.spitbol.patterns.match(...) 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Dale Stanbrough @ 2000-10-07 0:25 ` Ted Dennison 0 siblings, 0 replies; 9+ messages in thread From: Ted Dennison @ 2000-10-07 0:25 UTC (permalink / raw) Dale Stanbrough wrote: > I didn't have a problem with the Snobol part, (although i find > the use of 'Unrestricted_Access can make spitbol code a bit ugly); > it was the full package name syntax, and the strange formatting > that i found hard to cope with. Well, the strange formatting can probably be blamed on Deja, his newsreader. It has a nasty habit of inserting and deleting line breaks, seemingly at random. Whenever I post source code using Deja, I've taking to apologizing in advance for what it might end up doing to the formatting. I think the full package name syntax (in isolation) looks fine. But there really is no excuse for the random identifier casing. :-) Now that we have finished making fun of his style and typing capabilitites, I wonder if anyone can answer the poor bumwad's question... -- T.E.D. Home - mailto:dennison@telepath.com Work - mailto:dennison@ssd.fsi.com WWW - http://www.telepath.com/dennison/Ted/TED.html ICQ - 10545591 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gnat.spitbol.patterns.match(...) 2000-10-06 0:42 ` gnat.spitbol.patterns.match(...) dale 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Robert Dewar @ 2000-10-06 3:14 ` Ted Dennison 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Robert Dewar 2000-10-07 0:00 ` gnat.spitbol.patterns.match(...) Georg Bauhaus 1 sibling, 2 replies; 9+ messages in thread From: Ted Dennison @ 2000-10-06 3:14 UTC (permalink / raw) dale wrote: > Mr bumwadwrote: > > [a whole lot of stuff] > > ...and i thought Ada was supposed to be readable!!! Well...a lot of that was SPITBOL (a regular expression language). -- T.E.D. Home - mailto:dennison@telepath.com Work - mailto:dennison@ssd.fsi.com WWW - http://www.telepath.com/dennison/Ted/TED.html ICQ - 10545591 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gnat.spitbol.patterns.match(...) 2000-10-06 3:14 ` gnat.spitbol.patterns.match(...) Ted Dennison @ 2000-10-06 0:00 ` Robert Dewar 2000-10-07 0:00 ` gnat.spitbol.patterns.match(...) Georg Bauhaus 1 sibling, 0 replies; 9+ messages in thread From: Robert Dewar @ 2000-10-06 0:00 UTC (permalink / raw) In article <3A04F805.AB1D83DA@telepath.com>, Ted Dennison <dennison@telepath.com> wrote: > Well...a lot of that was SPITBOL (a regular expression > language). That's a lot of misinformation in a very short sentence :-) :-) 1. Spitbol is not a language, it is an implementation. Referring to Spitbol as a language would be like referring to GNAT as a language. The language is SNOBOL 4, designed by Ralph Griswold and coworkers at Bell Labs in the late 70's and early 80's. I also partipated in the language design. The reason that we call the package Spitbol in GNAT is fourfold: 1. It incorporates some of the extensions of SPITBOL 2. Most SNOBOL-4 users these days are using SPITBOL 3. It uses the pattern matching algorithms of SPITBOL 4. Since I wrote SPITBOL, it creates an useful connection 2. It has NOTHING at ALL to do with regular expressions. I really don't know where you got this idea. The whole point of SNOBOL 4 is that its pattern matching is based on context free grammars, and actually it is better to think of them as attribute grammars, since quite general semantic actions, including predicates can be included in a pattern. Indeed the use of regular expressions for matching is by comparison kludgy and very restrictive. To give an idea of the power of SNOBOL-4 pattern matching, it is quite feasible to write a pattern that matches only strings that are syntactically valid Ada 95 programs, and rejects all other strings. The syntax of this pattern would be reminiscent of the BNF used in the Ada RM to describe the syntax of Ada. Robert Dewar Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gnat.spitbol.patterns.match(...) 2000-10-06 3:14 ` gnat.spitbol.patterns.match(...) Ted Dennison 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Robert Dewar @ 2000-10-07 0:00 ` Georg Bauhaus 2000-10-07 0:00 ` gnat.spitbol.patterns.match(...) Georg Bauhaus 1 sibling, 1 reply; 9+ messages in thread From: Georg Bauhaus @ 2000-10-07 0:00 UTC (permalink / raw) Ted Dennison (dennison@telepath.com) wrote: : Well...a lot of that was SPITBOL (a regular expression language). Not beeing the one to judge SNOBOL4, but still having intense looks at it (and using it), thus finding "a regular expression language" rather misleading (for reasons in addition to those Robert Dewar has already given), here is a quote from J. Gimpel, Algorithms in SNOBOL4: "The SNOBOL series of programming languages through SNOBOL4 had only one datatype, the string. Even the arithmetic facilities of SNOBOL3 were implemented as operations on strings of digits rather than on machine integers. Because of this historical bias, and because the language is extaordinarily rich in string handling, SNOBOL4 is still regarded by some as exclusively a string language. Yet, all the basic facilities which one expects in a list processing language have been incorporated into SNOBOL4; these include the automatic allocation and freeing of storage, recursive functions, the pointer, and the data structure. Moreover, the notation is, for the most part, conventional, convenient and flexible. Were SNOBOL4 suddenly stripped of all its pattern matching capabilities, it would still be a powerful and convenient list-processing language." (p. 80) And easy enough to use! :-) With the GNAT library, and the ./examples directory, you get Ada with it's facilities combined with some from SNOBOL4, to make a handy toolset for, e.g. data preparation (called "data laundry", I believe, think of CGI as one example). NOte that Ada has types, so SNOBOL4's dodn't have to be "imported" :>. IMHO ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gnat.spitbol.patterns.match(...) 2000-10-07 0:00 ` gnat.spitbol.patterns.match(...) Georg Bauhaus @ 2000-10-07 0:00 ` Georg Bauhaus 0 siblings, 0 replies; 9+ messages in thread From: Georg Bauhaus @ 2000-10-07 0:00 UTC (permalink / raw) Georg Bauhaus (sb463ba@l1-hrz.uni-duisburg.de) wrote: : Ted Dennison (dennison@telepath.com) wrote: : "The SNOBOL series of programming languages through SNOBOL4 had only one correct: ^^^^^^3 Sorry. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2000-10-07 0:25 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2000-10-05 0:00 gnat.spitbol.patterns.match(...) bumwad 2000-10-06 0:42 ` gnat.spitbol.patterns.match(...) dale 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Robert Dewar 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Dale Stanbrough 2000-10-07 0:25 ` gnat.spitbol.patterns.match(...) Ted Dennison 2000-10-06 3:14 ` gnat.spitbol.patterns.match(...) Ted Dennison 2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Robert Dewar 2000-10-07 0:00 ` gnat.spitbol.patterns.match(...) Georg Bauhaus 2000-10-07 0:00 ` gnat.spitbol.patterns.match(...) Georg Bauhaus
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox