comp.lang.ada
 help / color / mirror / Atom feed
From: Geoff Bull <geoff@research.canon.com.au>
To: phantom119@my-deja.com
Subject: Re: help on Ada project
Date: 1999/12/01
Date: 1999-12-01T03:18:42+00:00	[thread overview]
Message-ID: <384494B7.A64C4821@research.canon.com.au> (raw)
In-Reply-To: 82204n$f3n$1@nnrp1.deja.com

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




  parent reply	other threads:[~1999-12-01  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-01  0:00 help on Ada project phantom119
1999-12-01  0:00 ` Ted Dennison
1999-12-01  0:00 ` Geoff Bull [this message]
1999-12-01  0:00 ` Peter Milliken
1999-12-02  0:00   ` John McCabe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox