comp.lang.ada
 help / color / mirror / Atom feed
From: aschwarz@acm.org (skidmarks)
Subject: Re: Question about Ada.Unchecked_Conversion
Date: 30 Oct 2004 03:23:10 -0700
Date: 2004-10-30T03:23:10-07:00	[thread overview]
Message-ID: <35f054ea.0410300223.773b722b@posting.google.com> (raw)
In-Reply-To: m2k6t934r9.fsf@mac.scrogneugneu.org

I don't have the full picture of what you're trying to do so my answer
may be off the mark.

When I build a custom lexor I include a (usually) 256 cell array. The
cell is mapped one-to-one with (any) 256 representation of the
character set in use, and 256 has the property of guaranteeing nor
constraint errors. The contents of each cell is a enumeration
representing the purpose of the mapped character. My lexer is built
around this.

For example:

  type enum { ign, sep, op, sym, num, hex, ... );

  type enum_Map is array ( Integer range 1 .. 256 ) of enum;

  Map : constant enum_Map := ( ign, ... sep, ... );

begin -- 

   if ( enum_Map( Character'Pos(char) ) = <> ) then <> end if;


or

   case enum_Map( Character'Pos(char) ) is
   when ign => <>
   when sep => <>
   when op  => <>
   when sym => <>
   when num => <>
  
 and so on.

I use a Moore Machine for my finite state machine, the arcs
representing the transition states (ign, sep, ...) and actions
associated with taking the transition.

Hope this helps.

art



  reply	other threads:[~2004-10-30 10:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-29 12:46 Question about Ada.Unchecked_Conversion Eric Jacoboni
2004-10-29 14:22 ` Dmitry A. Kazakov
2004-10-29 14:26 ` Jean-Pierre Rosen
2004-10-29 15:15 ` Nick Roberts
2004-10-29 15:47   ` Eric Jacoboni
2004-10-30 10:23     ` skidmarks [this message]
2004-10-30 16:30       ` Nick Roberts
2004-10-30 17:18         ` Eric Jacoboni
replies disabled

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