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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bb6ebeb41bf44573 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!transit.news.xs4all.nl!195.241.76.212.MISMATCH!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail Newsgroups: comp.lang.ada Subject: Re: character matching References: From: Ludovic Brenta Date: Sun, 15 Aug 2004 16:52:49 +0200 Message-ID: <87zn4wtpvi.fsf@insalien.org> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:ttKpy6V+3QXstmLJwXOyZOMhGy0= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tiscali bv NNTP-Posting-Date: 15 Aug 2004 16:53:16 CEST NNTP-Posting-Host: 83.134.237.35 X-Trace: 1092581596 dreader2.news.tiscali.nl 62359 83.134.237.35:34191 X-Complaints-To: abuse@tiscali.nl Xref: g2news1.google.com comp.lang.ada:2740 Date: 2004-08-15T16:53:16+02:00 List-Id: "John J" writes: > Thanks for the suggestions; however, I'm trying to learn a bit about > the syntax and capabilities of ADA. Would someone be kind enough to > give me some examples of how I can use ADA to character match. ie, > different ways I can use '*', '&' to successfully recognise words > and sentences. > > Thanks type Category is (Whitespace, Punctuation, Letter, Digit, Other); function Category_Of (C : in Character) return Category is begin case C is when ' ' | ASCII.TAB => return Whitespace; when ',' | '.' | '!' | ';' | ':' | '?' => return Punctuation; when 'a' .. 'z' | 'A' .. 'Z' => return Letter; when '0' .. '9' => return Digit; when others => return Other; end case; end Category_Of; I hope this helps you move forward. Is this a homework assignment? (note that in Ada, a "case" statement is required to process all possible values of the case_expression (here, C); the compiler will tell you if you forgot some values, unless as above you use "when others"). -- Ludovic Brenta.