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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,323cf9d74a4ce4ed X-Google-Attributes: gid103376,public From: Geoff Bull Subject: Re: help on Ada project Date: 1999/12/01 Message-ID: <384494B7.A64C4821@research.canon.com.au>#1/1 X-Deja-AN: 555128895 Content-Transfer-Encoding: 7bit References: <82204n$f3n$1@nnrp1.deja.com> To: phantom119@my-deja.com Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@research.canon.com.au X-Trace: cass.research.canon.com.au 944018322 26141 203.12.174.254 (1 Dec 1999 03:18:42 GMT) Organization: Canon Information Systems Research Australia Mime-Version: 1.0 NNTP-Posting-Date: 1 Dec 1999 03:18:42 GMT Newsgroups: comp.lang.ada Date: 1999-12-01T03:18:42+00:00 List-Id: phantom119@my-deja.com wrote: > > I need some help on Ada, we are to create a > lexical analyzer and we are stuck on the fact that > it's giving us some problems on string comparison, > we are using a case statement to compare strings, > since just a few words the analyzer should > recognize for example "begin" and print out on the > screen TBegin, we are using a case statement but > for some reason I guess we are not using the right > syntax, any suggestions on how would you do that? I assume this is a homework assignment? For case statement syntax see the Ada Reference Manual: http://www.adahome.com/rm95/rm9x-05-04.html In short, you can't use a case statement to compare strings, because they are not a discrete type. Since you only have a few strings you could just use if statements. For a more extensible approach, you could search a table. You might want to study the gnat source which contains a good example of a lexical analyzer. ftp://cs.nyu.edu/pub/gnat/gnat-3.12p-src.tar.gz start in the file scn.adb