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=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,166ddf42d0dfe75b X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Help with Ada.Strings.Fixed.Find_Token Date: 1999/10/21 Message-ID: <7unp5m$glg$1@nnrp1.deja.com>#1/1 X-Deja-AN: 538845487 References: <000b8d9b.4395da36@usw-ex0101-004.remarq.com> X-Http-Proxy: 1.0 x22.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Thu Oct 21 19:22:35 1999 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 1999-10-21T00:00:00+00:00 List-Id: In article <000b8d9b.4395da36@usw-ex0101-004.remarq.com>, Shawn Barber wrote: > Does anyone have an example of Find_Token in use. I'm currently using > Index to find the start and end position of my search string but I'd > like to see if Find_Token would be more effective in my Find_Token (Source, ... Test => Inside) is roughly equivalent to doing First := Index (Source, ...); Last := Index (Source(First..Source'last), Test => Outside), If you were going to do that anyway, it would be useful. But I really think Find_Token is more trouble than it is worth unless all the following apply: 1 You don't care where in the source string the token is found. 2 The string you want to locate is a coherent set of characters for which any permutation or combination in any number would be valid. 3 The character set is also exclusive. By that I mean there is *no* permutation of combination of any number those characters that could appear in the search string that you would *not* want matched. For example, suppose you want to use Find_Token to match an integer, which you would like to be able to pass straight to Integer'Value without having to trap Constraint_Error's. If you specify "0123456789" as the set of characters to match, then you would not match negatives, and would match parts of identifiers with numbers imbedded in them and integers with leading 0's (which you would like to be invalid). If you try to fix the negative problem by specifying "-0123456789", now strings like "hyper-extend" or "- 5" will report a 1 character match on the hyphen character. If your parsing needs are very simple, this isn't a bad approach. If your needs are more complicated, then I suggest you look into using either the Gnat.Snobol packages that come with Gnat, or OpenToken ( http://www.telepath.com/dennison/Ted/OpenToken/OpenToken.html ). -- T.E.D. Sent via Deja.com http://www.deja.com/ Before you buy.