comp.lang.ada
 help / color / mirror / Atom feed
From: roderick.chapman@googlemail.com
Subject: Re: SPARK Examiner -- visibility of Ada.Strings.Unbounded (and probably lots of other packages)
Date: Thu, 26 Mar 2009 09:51:48 -0700 (PDT)
Date: 2009-03-26T09:51:48-07:00	[thread overview]
Message-ID: <304930c9-d79d-4de7-89fb-706a35986f93@c11g2000yqj.googlegroups.com> (raw)
In-Reply-To: OPWdnbuqg7uyN1bUnZ2dnUVZ8qOWnZ2d@posted.plusnet

Here's a short example of shadowing and using Ada.Strings
and Ada.Strings.Unbounded.  You'll also need the
spec and body of SPARK_IO supplied with the SPARK tools
distribution.
 - Rod

----------------------

spark.sw
--------

-index=spark -flow=data -warn=all

spark.idx
---------

ada.strings spec is in ada-strings.shs
ada.strings.unbounded spec is in ada-strings-unbounded.shs
spark_io spec is in spark_io.ads

all.wrn
-------

pragma all
hidden
notes

ada-strings.shs
---------------

package Ada.Strings
is
   Space : constant Character := ' ';

   -- Wide_Space is not SPARK

   -- Exceptions Length_Error etc are not SPARK

   type Alignment  is (Left, Right, Center);

   -- Cannot overload Left and Right in SPARK
   -- type Truncation is (Left, Right, Error);

   type Membership is (Inside, Outside);

   type Direction  is (Forward, Backward);

   -- Cannot overload Left and Right in SPARK
   -- type Trim_End   is (Left, Right, Both);

end Ada.Strings;


ada-strings-unbounded.shs
-------------------------

--# inherit Ada.Strings;
package Ada.Strings.Unbounded
is
   -- Just a few things here for example

   type Unbounded_String is private;

   Null_Unbounded_String : constant Unbounded_String;

   function Length (Source : in Unbounded_String) return Natural;

   function To_Unbounded_String (Source : in String)
      return Unbounded_String;

   -- Add more stuff here if it's legal SPARK

private
   --# hide Ada.Strings.Unbounded;
end Ada.Strings.Unbounded;


main.adb
--------

with Ada.Strings.Unbounded,
     SPARK_IO;
--# inherit Ada.Strings.Unbounded,
--#         SPARK_IO;

--# main_program;
procedure Main
--# global in out SPARK_IO.File_Sys;
is
   X : Ada.Strings.Unbounded.Unbounded_String;
   L : Natural;
begin
   X := Ada.Strings.Unbounded.To_Unbounded_String ("Wibble");
   L := Ada.Strings.Unbounded.Length (X);
   if L = 6 then
      SPARK_IO.Put_Line (SPARK_IO.Standard_Output, "Success", 0);
   else
      SPARK_IO.Put_Line (SPARK_IO.Standard_Output, "Failure", 0);
   end if;
end Main;






      parent reply	other threads:[~2009-03-26 16:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26 14:50 SPARK Examiner -- visibility of Ada.Strings.Unbounded (and probably lots of other packages) Tim Rowe
2009-03-26 15:13 ` Ludovic Brenta
2009-03-26 15:18   ` Georg Bauhaus
2009-03-26 15:35     ` roderick.chapman
2009-03-26 17:06       ` Tim Rowe
2009-03-26 19:13         ` Tim Rowe
2009-03-27  8:27           ` JP Thornley
2009-03-27  8:34             ` roderick.chapman
2009-03-27 16:03               ` Tim Rowe
2009-03-26 15:40     ` roderick.chapman
2009-03-26 16:15   ` Tim Rowe
2009-03-26 16:26     ` roderick.chapman
2009-03-26 16:30     ` JP Thornley
2009-03-26 16:51     ` roderick.chapman [this message]
replies disabled

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