comp.lang.ada
 help / color / mirror / Atom feed
From: jduarte@siam.ICS.UCI.EDU (Jose_Duarte)
Subject: (none)
Date: 8 Aug 90 21:12:01 GMT	[thread overview]
Message-ID: <9008081400.aa18414@PARIS.ICS.UCI.EDU> (raw)

Hello Folks,

	I am currently writing a routine in Ada under Berkeley Unix 4.2
using the Verdix ADA compiler 6.0.  I am using the standard Text_IO
routines GET and PUT to implement a function to save a tree in text
format.  I save the tree using a depth-first algorithm, and this means
that I have to call the Save_Tree function recursively...I am using a
Sun 4 machine to work on, and I get a BUS ERROR once in a while...No
exceptions are raised...just a BUS ERROR...It doesn't happen always,
and my routine doesn't "bite the dust" in the same place when I do
get a BUS ERROR...My question is: Has anyone else had the same problem ?
I know this is too general a question, but I just thought I'd ask...

Jose Duarte.
------------------------------------------------------
CODE:

with Lines,
     Text_IO,
     Tree_Generation,
     File_Manager,
     Command_Line,
     CTA_System,
     Tables;






package body Tree_Traversal is






------------------------------------------------------
-- procedure Print_Tree_2
--
-- This procedure Prints out the Classification Tree
-- using a depth-first recursive algorithm.  The User's
-- Manual displays a Tree and a sample tree ouput. If
-- The Indentation_Level is too long, then the output
-- will be messed up. Tough Luck !!!
--
-- There are three cases possible when Printing the tree:
--
-- 1. The Node_Ptr parameter is null.
--         The words "null node" are ouput
--
-- 2. The Node_Ptr parameter points to a terminal node:
--         The Node classification is determined from the
--         node record field "Classification", and then the
--         symbols <+> or <-> or <*> are output.
--
-- 3. The Node_Ptr points to a NONTERMINAL record node:
--         The Metric Name is extracted from the Metrics
--         Table according to the "Metric_Code" field in the
--         record.  Next, the Arc_List pointer is initialized
--         to point to the first arc.  A "while" loop calls
--         the Print_Tree procedure recursively for each arc
--         in the arcs_list with a new Indentation_Level.
--
------------------------------------------------------
procedure Print_Tree_2(F                : Text_IO.File_Type;
                       Node_Ptr         : Tree_Generation.Tree_Node_Pointer;
                       Indentation_Level: Natural ) is

use File_Manager,CTA_System,Tree_Generation,Text_IO;
Arc_List : Tree_Arc_Pointer;

Metric_Type: Tables.Value_Type;
Metric_Code: POSITIVE;
Temp_Str   : Lines.Normal_Line;
Int1,Int2  : INTEGER;
F1,F2      : FLOAT;

begin
   New_Line(F);
   -- indent the proper number of columns:
   For X in NATURAL range 1..Indentation_Level loop
       Put(F,'|');
   end loop;


   -- case 1: The pointer is a null pointer
   if (Node_Ptr = null) then
      Put(F,"<null node>");
      return;
   end if;


   -- case 2: The pointer points to a terminal node
   if (Is_Terminal(Node_Ptr)) then
      case Return_Classification(Node_Ptr) is
          when CTA_System.P => Put(F,"<+>");
          when CTA_System.N => Put(F,"<->");
          when CTA_System.Z => Put(F,"<Z>");
          when CTA_System.M => Put(F,"<M>");
          when CTA_System.D => Put(F,"<D>");
          when CTA_System.U => Put(F,"<U>");
      end case;
      -- New_Line(F);
      return;
   end if;

   -- case 3: a NONTERMINAL
   -- it's not null and not a terminal
   -- i.e. it's a nonterminal:

   -- put out Metric Name - a conversion is required:
   Put(F,Lines.IMAGE(Get_Metric_Name(Return_Metric_Code(Node_Ptr))));
   -- New_Line(F);

   -- start off with the first child node:
   Arc_List := Get_Arc_List_Pointer(Node_Ptr);

   Metric_Type := Get_Metric_Type(Return_Metric_Code(Node_Ptr));
   while (Arc_List /= null) loop
       Get_Range_Values(Arc_List,Temp_Str,Int1,Int2,F1,F2);
       if NOT (Is_Terminal(Get_Child_Node_From_Arc(Arc_List))) then
       New_Line(F);
       For X in NATURAL range 1..Indentation_Level+4 loop
          Put(F,' ');
       end loop;
       case Metric_Type is
         when Tables.CHAR  =>
              Put(F," ( " & Lines.IMAGE(Temp_Str) & " ) ");
         when Tables.INT   =>
              Put(F, " ( ");
              Put(F, INTEGER'IMAGE(Int1));
              Put(F," , ");
              Put(F, INTEGER'IMAGE(Int2));
              Put(F, " ) ");
         when Tables.REAL  =>
              Put(F, " ( ");
              CTA_System.CTA_Floats.Put(F,F1,1,3,3);
              Put(F," , ");
              CTA_System.CTA_Floats.Put(F, F2,1,3,3);
              Put(F, " ) ");
         end case;
       end if;
       Print_Tree_2(F,Get_Child_Node_From_Arc(Arc_List), Indentation_Level+5);

       if (Is_Terminal(Get_Child_Node_From_Arc(Arc_List))) then
       case Metric_Type is
         when Tables.CHAR  =>
              Put(F," ( " & Lines.IMAGE(Temp_Str) & " ) ");
         when Tables.INT   =>
              Put(F, " ( ");
              Put(F, INTEGER'IMAGE(Int1));
              Put(F," , ");
              Put(F, INTEGER'IMAGE(Int2));
              Put(F, " ) ");
         when Tables.REAL  =>
              Put(F, " ( ");
              CTA_System.CTA_Floats.Put(F,F1,1,3,3);
              Put(F," , ");
              CTA_System.CTA_Floats.Put(F, F2,1,3,3);
              Put(F, " ) ");
       end case;
       -- New_Line(F);
       end if;
       Arc_List := Next_Arc(Arc_List);
   end loop;
end Print_Tree_2;





------------------------------------------------------
procedure Print_Tree(Node_Ptr         : Tree_Generation.Tree_Node_Pointer;
                     Indentation_Level: Natural := 0) is
use Text_IO;

F: File_Type;

begin
   -- Get the output filename from the command-line:
   Lines.Assign(CTA_System.Filename,Command_Line.argv(2).s);
   CREATE(F,Out_File,Lines.IMAGE(CTA_System.Filename));
   -- Save the tree to a file:
   Print_Tree_2(F,Node_Ptr,Indentation_Level);
   CLOSE(F);
end;





end Tree_Traversal;

             reply	other threads:[~1990-08-08 21:12 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-08-08 21:12 Jose_Duarte [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-07-23  0:00 <None> **
1993-09-01  7:24 (none) N.B. Hedd
1993-01-27 23:32 <none> xim
1993-01-27 23:09 <none> xim
1993-01-27 16:39 <none> xim
1993-01-27 16:29 <none> slava
1993-01-26 23:13 <none> xim
1992-12-04  4:03 (none) Michael Feldman
1992-12-03 16:57 (none) dog.ee.lbl.gov!overload.lbl.gov!agate!linus!linus.mitre.org!news!emery
1992-12-03 15:59 (none) Tuck er Taft
1992-12-03 14:43 (none) dog.ee.lbl.gov!overload.lbl.gov!agate!usenet.ins.cwru.edu!magnus.acs.ohio
1992-04-03 15:57 <none> David Emery
1991-09-20 18:58 <None> cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usen
1991-06-20 13:18 (none) Eric E. Mays 52202
1991-06-20 13:18 (none) Eric E. Mays 52202
1991-05-27  8:20 (none) Giorgio del rio
1991-05-14 13:35 <None> Ace Stewart
1991-03-26 20:38 (none) Eric E. Mays 52202
1991-02-28 17:50 (none) Giorgio del rio
1991-01-10 16:38 (none) GS-09 Ken McCook;SCDD
1990-09-20 18:21 (none) "John P. Solomond, Director, AJPO"
1990-09-24  8:52 ` (none) Richard A. O'Keefe
1990-05-07 18:37 (none) Ken McCook;SCDQ;
1990-02-14 16:43 (none) Dave Williamson
1989-09-02 22:13 (none) cdonalds
1989-09-04  1:43 ` (none) Richard O'Keefe
1989-04-14 11:43 (none) jrovert
1989-04-03 13:23 (none) Norman Cohen
1989-03-09 22:07 (none) Norman Cohen
1989-03-08 13:59 (none) Norman Cohen
1989-03-06 19:20 (none) TSIGLER
1989-03-06 14:49 (none) Javier Romanach / GMV
1989-02-24  0:46 (none) Marie T. Minogue
1989-02-16 17:05 (none) Richard.S.D'Ippolito
1989-01-13 17:11 (none) NCOHEN
1988-11-21 22:34 (none) Mark Nelson
1988-11-07 12:52 (none) gita R. Rajan
1988-10-20 18:40 (none) sdl
1988-09-16  9:51 (none) TVOVERBE
1988-06-03 12:08 (none) Greg Gicca
1988-04-07 20:15 (none) sdl
1988-03-17  1:24 (none) sdl
1988-03-12  2:48 (none) sdl
1988-03-09  3:18 (none) sdl
1988-03-07 15:16 (none) amb
1987-12-23 10:54 (none) CARNAL
1987-09-15 19:39 (none) Alex Blakemore
1987-08-28 15:31 (none) LOUBOUTIN
1987-08-25 16:58 (none) LOUBOUTIN
1987-08-25 16:58 (none) LOUBOUTIN
1987-06-09 17:17 (none) SARX
1987-06-04 16:21 (none) seafac
1987-05-29  4:57 (none) postmaster
1987-05-27  3:03 (none) jklemens
1987-03-14  1:22 (none) CONTR47
1987-01-16 16:24 (none) FRASER
1986-12-21 23:16 (none) diby
1986-09-22 16:36 (none) "Pat Rogers, High Tech Lab"
1986-09-22 16:36 (none) "Pat Rogers, High Tech Lab"
1986-06-05 19:39 (none) info-ada-request
1986-06-05 12:15 (none) info-ada-request
1986-04-08 14:54 (none) Stephen.Hutchinson
1986-03-16 18:52 (none) info-ada-request
1986-02-03 19:07 (none) GAUSTIN
1985-12-05 21:42 (none) , , 
1985-12-05 20:54 (none) , 
1985-12-05 20:50 (none) info-ada
1985-12-05 17:45 (none) info-ada
1985-12-08 21:08 ` (none) Jay R. Ashworth
1985-12-05 15:46 (none) info-ada
1985-12-05  6:09 (none) info-ada
1985-12-06  1:04 ` (none) info-ada
1985-12-06  1:37 ` (none) info-ada
1985-12-06  1:47 ` (none) info-ada
1985-12-04 18:34 (none) RCONN
1985-12-06  1:02 ` (none) info-ada
1985-12-06  1:32 ` (none) info-ada
1985-12-06  1:46 ` (none) info-ada
1985-12-04 16:41 (none) RCONN
1985-12-06  0:59 ` (none) info-ada
1985-12-06  1:29 ` (none) info-ada
1985-12-06  1:46 ` (none) info-ada
1985-12-04  7:50 (none) , 
1985-12-06  0:47 ` (none) info-ada
1985-12-06  1:13 ` (none) info-ada
1985-12-06  1:44 ` (none) info-ada
1985-12-03 22:07 (none) , 
1985-12-06  0:47 ` (none) info-ada
1985-12-06  1:10 ` (none) info-ada
1985-12-06  1:42 ` (none) info-ada
1985-12-03 11:13 (none) , 
1985-12-06  0:42 ` (none) info-ada
1985-12-06  1:08 ` (none) info-ada
1985-12-06  1:41 ` (none) info-ada
1985-12-03  4:24 (none) info-ada
1985-12-06  0:41 ` (none) info-ada
1985-12-06  1:06 ` (none) info-ada
1985-12-06  1:40 ` (none) info-ada
1985-12-06  1:48 ` (none) info-ada
1985-12-12 22:22   ` (none) info-ada
1985-12-02 20:44 (none) Stachour.CSC_RP
1985-12-06  0:41 ` (none) info-ada
1985-11-29 14:35 Ada Professionalism Document Edward V. Berard
1985-12-04  9:09 ` (none) , 
1985-12-06  0:49   ` (none) info-ada
1985-12-10 11:32     ` (none) info-ada
1985-12-06  1:15   ` (none) info-ada
1985-12-06  1:45   ` (none) info-ada
1985-12-06  5:04   ` (none)??? Dick Dunn
replies disabled

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