From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4f316de357ae35e9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-05 00:57:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.gamma.ru!Gamma.RU!carrier.kiev.ua!news.lucky.net!not-for-mail From: Oleg Goodyckov Newsgroups: comp.lang.ada Subject: Re: FAQ and string functions Date: Mon, 5 Aug 2002 10:18:34 +0300 Organization: unknown Distribution: world Message-ID: <20020805101834.B1660@videoproject.kiev.ua> References: <20020730093206.A8550@videoproject.kiev.ua> <4519e058.0207300548.15eeb65c@posting.google.com> <20020731104643.C1083@videoproject.kiev.ua> <4519e058.0208010629.5e6182ca@posting.google.com> <20020801194720.Q1080@videoproject.kiev.ua> <4519e058.0208020605.5ab7e092@posting.google.com> Reply-To: og@videoproject.kiev.ua NNTP-Posting-Host: news.lucky.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.lucky.net 1028534223 18507 193.193.193.102 (5 Aug 2002 07:57:03 GMT) X-Complaints-To: usenet@news.lucky.net NNTP-Posting-Date: Mon, 5 Aug 2002 07:57:03 +0000 (UTC) X-Return-Path: oleg@videoproject.kiev.ua Xref: archiver1.google.com comp.lang.ada:27688 Date: 2002-08-05T10:18:34+03:00 List-Id: On Fri, Aug 02, 2002 at 07:05:33AM -0700, Ted Dennison wrote: > Oleg Goodyckov wrote in message news:<20020801194720.Q1080@videoproject.kiev.ua>... > > Saing onestly, I'm very surprized, that so basic and simple operation as > > splitting/joining of string is not present in Ada natively. And most > > Well, stated that way, it *is* present. Splitting strings (or any > other array) is done with slices, and joining them (any array) is done > with the "&" operator. Those are indeed the basic operations available > to arrays (along with indexing, and bounds attributes like 'first). As > I understand it, your problem isn't with splitting and joining, its > with figuring out where to do the splitting and joining. Correct? Of cause not in splitting/joining itself. Look at drop of water, where problem is mirrored. Below is slice of Gnat.Spitbol.Patterns package (g-spipat.ads): -- For an example of a recursive pattern, let's define a pattern -- that is like the built in Bal, but the string matched is balanced -- with respect to square brackets or curly brackets. -- The language for such strings might be defined in extended BNF as -- ELEMENT ::= <any character other than [] or {}> -- | '[' BALANCED_STRING ']' -- | '{' BALANCED_STRING '}' -- BALANCED_STRING ::= ELEMENT {ELEMENT} -- Here we use {} to indicate zero or more occurrences of a term, as -- is common practice in extended BNF. Now we can translate the above -- BNF into recursive patterns as follows: -- Element, Balanced_String : aliased Pattern; -- . -- . -- . -- Element := NotAny ("[]{}") -- or -- ('[' & (+Balanced_String) & ']') -- or -- ('{' & (+Balanced_String) & '}'); -- Balanced_String := Element & Arbno (Element); -- Note the important use of + here to refer to a pattern not yet -- defined. Note also that we use assignments precisely because we -- cannot refer to as yet undeclared variables in initializations. -- Now that this pattern is constructed, we can use it as though it -- were a new primitive pattern element, and for example, the match: -- Match ("xy[ab{cd}]", Balanced_String * Current_Output & Fail); -- will generate the output: -- x -- xy -- xy[ab{cd}] -- y -- y[ab{cd}] -- [ab{cd}] -- a -- ab -- ab{cd} -- b -- b{cd} -- {cd} -- c -- cd -- d Good! But where can I find this last output? Somhere in "Current_Output". Where is it? In current output file? Why there? Suggest: because Ada has a lack of dynamically infrastructure. And external file is such a most apropriate implementation of it. It likes as pushing a problem out of mind: data pushed out of program, problem pushed out of mind. No data - no problem. But I'll be glad to find this convinient dynaic infrastructure. Having it - it will be very simple to build any variation of split/join of string. Suggest: big amount of code in support of realization of function "split" is hidden realization of dynamic infrastructure needed for this purpose.