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.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d955a56d21742fee X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-19 18:36:39 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!oleane.net!oleane!deine.net!intgwpad.nntp.telstra.net!news.telstra.net!nsw.nnrp.telstra.net!not-for-mail From: "ProLogic" Newsgroups: comp.lang.ada References: <3ce7c19a@news.comindico.com.au> <3ce81da1$1@news.comindico.com.au> Subject: Re: An example was Re: Tokens X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Original-NNTP-Posting-Host: 203.194.40.32 Message-ID: <3ce85325@news.comindico.com.au> X-Original-Trace: 20 May 2002 11:36:37 +1000, 203.194.40.32 Organization: Comindico Australia Pty Ltd Date: Mon, 20 May 2002 11:36:45 +1000 NNTP-Posting-Host: 203.194.27.1 X-Complaints-To: abuse@telstra.net X-Trace: nsw.nnrp.telstra.net 1021858595 203.194.27.1 (Mon, 20 May 2002 11:36:35 EST) NNTP-Posting-Date: Mon, 20 May 2002 11:36:35 EST Xref: archiver1.google.com comp.lang.ada:24394 Date: 2002-05-20T11:36:45+10:00 List-Id: Thanks chris. Recusion is fine. "chris.danx" wrote in message news:dkWF8.34770$Iv.4001930@news6-win.server.ntlworld.com... > > "ProLogic" wrote in message > news:3ce81da1$1@news.comindico.com.au... > > Could I you show me a working example of this please? I've read that > entire > > section you have shown me, hmmm > > This is a quicky example I wrote in 10mins. It uses recursion which I think > is clearer in this example, but if it's not clear what is going on I'll > rewrite it with a loop no bother. > > If OE mangles it, send me an email (change spamoff to chris) > > HTH, > Chris > > > with ada.strings.fixed; -- find_token is here; > with ada.strings.maps; -- character_set is here; > with ada.text_io; > > use ada.strings; -- outside/inside are here; > > procedure token_example is > > -- prints all the "words" in a string, where > -- delims is the set of characters regarded as whitespace. > -- > procedure what_words (str : in string; > delims : in maps.character_set) is > first : positive := 1; > last : natural := 0; > begin > fixed.find_token (str, > delims, > ada.strings.outside, > first, > last); > > -- if last = 0 there are no more tokens, so we stop, > -- otherwise we recur! > -- > if last > 0 then > ada.text_io.put (str(first..last) & " & "); > > what_words (str (last + 1..str'last), > delims); > end if; > end what_words; > > -- a simple character set! > -- > something_simple : maps.character_set := maps.to_set (" !?,"); > > begin > what_words ("My name is bob! And I like skinny dipping parties how about > you?", > something_simple); > end token_example; > > > > >