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,5e9097cf4f3eaf57 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.230.194 with SMTP id ta2mr1971485pbc.3.1333645963282; Thu, 05 Apr 2012 10:12:43 -0700 (PDT) MIME-Version: 1.0 Path: r9ni22072pbh.0!nntp.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: deuteros Newsgroups: comp.lang.ada Subject: Re: Checking to see if a string is a letter Date: Thu, 5 Apr 2012 17:12:42 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <2030859.0.1333426683573.JavaMail.geo-discussion-forums@pbbnv8> Injection-Date: Thu, 5 Apr 2012 17:12:42 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="QF15JMfcBFrmxWoj0L/Q9g"; logging-data="4601"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nU7iCJZJGbE6a9NcOKRaDq35uteGrhTs=" User-Agent: Xnews/2009.05.01 X-Antivirus-Status: Clean X-Antivirus: avast! (VPS 120405-0, 04/05/2012), Outbound message Cancel-Lock: sha1:dAnoDYW8PV394pHST2UcaiuDkLM= Date: 2012-04-05T17:12:42+00:00 List-Id: On Tue 03 Apr 2012 04:26:40a, Simon Wright wrote in news:m2k41xi5kv.fsf@pushface.org: > deuteros writes: > >> On Tue 03 Apr 2012 01:15:27a, Jeffrey Carter >> wrote in >> news:jle13q$ale$1@tornado.tornevall.net: >> >>> What do you mean by "contains a single letter"? >> >> I mean the string contains a single letter and nothing more. For >> example: >> >> a - Legal >> A - Legal >> aa - Illegal >> a1 - Illegal > > Then for a start the length of the string needs to be 1. > > If it is, the first (and only!) character needs to be a lower- or > upper-case letter. There are (at least) three ways of doing this: > > * declare an array of Boolean indexed by Character, with the elements > indexed by letters set to True and the others to False, and index by > the character to be tested; > > * declare two subtypes of character ("Character range 'a' .. 'z'", for > instance) and check whether the character to be tested is 'in' either > of the subtypes; > > * use the standard library, Ada.Characters.Handling.Is_Letter (probably > the easiest for you!) Alright, here's my function: function isVariable(token: in String) return Boolean is ParserException : Exception; begin if(token'Length = 1) then return (Is_Letter(token(1))); end if; raise ParserException with ("Not a letter : " & token); end isVariable; But I'm getting this warning: warning: index for "token" may assume lower bound of 1 warning: suggested replacement: "token'First + -1"